Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(redshift): adds classic or elastic resize type option #21084

Merged
merged 3 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/@aws-cdk/aws-redshift/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,14 @@ export interface ClusterProps {
* @default false
*/
readonly publiclyAccessible?: boolean

/**
* A boolean value indicating whether the resize operation is using the classic resize process.
* If you don't provide this parameter or set the value to false, the resize type is elastic.
*
* @default - Elastic resize type
*/
readonly classicResizing?: boolean
}

/**
Expand Down Expand Up @@ -485,6 +493,7 @@ export class Cluster extends ClusterBase {
// Encryption
kmsKeyId: props.encryptionKey?.keyId,
encrypted: props.encrypted ?? true,
classic: props.classicResizing,
});

cluster.applyRemovalPolicy(removalPolicy, {
Expand Down
67 changes: 67 additions & 0 deletions packages/@aws-cdk/aws-redshift/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,73 @@ test('default child returns a CfnCluster', () => {
expect(cluster.node.defaultChild).toBeInstanceOf(CfnCluster);
});

test.each([
['elastic', false],
['classic', true],
])('resize type (%s)', (_, classicResizing) => {
// WHEN
new Cluster(stack, 'Redshift', {
masterUser: {
masterUsername: 'admin',
masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),
},
classicResizing,
vpc,
});

// THEN
Template.fromStack(stack).hasResource('AWS::Redshift::Cluster', {
Properties: {
AllowVersionUpgrade: true,
MasterUsername: 'admin',
MasterUserPassword: 'tooshort',
ClusterType: 'multi-node',
AutomatedSnapshotRetentionPeriod: 1,
Encrypted: true,
NumberOfNodes: 2,
NodeType: 'dc2.large',
DBName: 'default_db',
PubliclyAccessible: false,
ClusterSubnetGroupName: { Ref: 'RedshiftSubnetsDFE70E0A' },
VpcSecurityGroupIds: [{ 'Fn::GetAtt': ['RedshiftSecurityGroup796D74A7', 'GroupId'] }],
Classic: classicResizing,
},
DeletionPolicy: 'Retain',
UpdateReplacePolicy: 'Retain',
});
});

test('resize type not set', () => {
// WHEN
new Cluster(stack, 'Redshift', {
masterUser: {
masterUsername: 'admin',
masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),
},
vpc,
});

// THEN
Template.fromStack(stack).hasResource('AWS::Redshift::Cluster', {
Properties: {
AllowVersionUpgrade: true,
MasterUsername: 'admin',
MasterUserPassword: 'tooshort',
ClusterType: 'multi-node',
AutomatedSnapshotRetentionPeriod: 1,
Encrypted: true,
NumberOfNodes: 2,
NodeType: 'dc2.large',
DBName: 'default_db',
PubliclyAccessible: false,
ClusterSubnetGroupName: { Ref: 'RedshiftSubnetsDFE70E0A' },
VpcSecurityGroupIds: [{ 'Fn::GetAtt': ['RedshiftSecurityGroup796D74A7', 'GroupId'] }],
},
DeletionPolicy: 'Retain',
UpdateReplacePolicy: 'Retain',
});
});

function testStack() {
const newTestStack = new cdk.Stack(undefined, undefined, { env: { account: '12345', region: 'us-test-1' } });
newTestStack.node.setContext('availability-zones:12345:us-test-1', ['us-test-1a', 'us-test-1b']);
Expand Down