Skip to content

Commit

Permalink
Merge branch 'aws:main' into 28462-aws-events-match-wildcard
Browse files Browse the repository at this point in the history
  • Loading branch information
jaw111 authored Nov 13, 2024
2 parents 4f8520c + b763d86 commit 7e27759
Show file tree
Hide file tree
Showing 15 changed files with 1,740 additions and 25 deletions.
24 changes: 24 additions & 0 deletions packages/@aws-cdk/aws-redshift-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@ const cluster = new Cluster(this, 'Redshift', {
});
```

## Availability Zone Relocation

By using [relocation in Amazon Redshift](https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-recovery.html), you allow Amazon Redshift to move a cluster to another Availability Zone (AZ) without any loss of data or changes to your applications.
This feature can be applied to both new and existing clusters.

To enable this feature, set the `availabilityZoneRelocation` property to `true`.

```ts
import * as ec2 from 'aws-cdk-lib/aws-ec2';

declare const vpc: ec2.IVpc;

const cluster = new Cluster(this, 'Redshift', {
masterUser: {
masterUsername: 'admin',
},
vpc,
nodeType: NodeType.RA3_XLPLUS,
availabilityZoneRelocation: true,
});
```

**Note**: The `availabilityZoneRelocation` property is only available for RA3 node types.

## Connecting

To control who can access the cluster, use the `.connections` attribute. Redshift Clusters have
Expand Down
14 changes: 14 additions & 0 deletions packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,15 @@ export interface ClusterProps {
* @default - false
*/
readonly multiAz?: boolean;

/**
* Whether to enable relocation for an Amazon Redshift cluster between Availability Zones after the cluster is created.
*
* @see https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-recovery.html
*
* @default - false
*/
readonly availabilityZoneRelocation?: boolean;
}

/**
Expand Down Expand Up @@ -584,6 +593,10 @@ export class Cluster extends ClusterBase {
}
}

if (props.availabilityZoneRelocation && !nodeType.startsWith('ra3')) {
throw new Error(`Availability zone relocation is supported for only RA3 node types, got: ${props.nodeType}`);
}

this.cluster = new CfnCluster(this, 'Resource', {
// Basic
allowVersionUpgrade: true,
Expand Down Expand Up @@ -613,6 +626,7 @@ export class Cluster extends ClusterBase {
elasticIp: props.elasticIp,
enhancedVpcRouting: props.enhancedVpcRouting,
multiAz: props.multiAz,
availabilityZoneRelocation: props.availabilityZoneRelocation,
});

this.cluster.applyRemovalPolicy(removalPolicy, {
Expand Down
33 changes: 33 additions & 0 deletions packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,39 @@ test('publicly accessible cluster', () => {
});
});

test('availability zone relocation enabled', () => {
// WHEN
new Cluster(stack, 'Redshift', {
masterUser: {
masterUsername: 'admin',
},
vpc,
availabilityZoneRelocation: true,
nodeType: NodeType.RA3_XLPLUS,
});

// THEN
Template.fromStack(stack).hasResourceProperties('AWS::Redshift::Cluster', {
AvailabilityZoneRelocation: true,
});
});

test.each([
NodeType.DC1_8XLARGE,
NodeType.DC2_LARGE,
])('throw error when availability zone relocation is enabled for invalid node type %s', (nodeType) => {
expect(() => {
new Cluster(stack, 'Redshift', {
masterUser: {
masterUsername: 'admin',
},
vpc,
availabilityZoneRelocation: true,
nodeType,
});
}).toThrow(`Availability zone relocation is supported for only RA3 node types, got: ${nodeType}`);
});

test('imported cluster with imported security group honors allowAllOutbound', () => {
// GIVEN
const cluster = Cluster.fromClusterAttributes(stack, 'Database', {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7e27759

Please sign in to comment.