Skip to content

Commit 9ac3084

Browse files
feat(redshift-alpha): maintenance track name (#33552)
### Issue # (if applicable) None ### Reason for this change Redshift supports for the specifying [maintenance track name](https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-considerations.html#rs-mgmt-maintenance-tracks) but L2 Cluster construct does not support this feature. ### Description of changes - Define `MaintenanceTrackName` enum - Add `maintenanceTrackName` prop to `ClusterProps` ### Describe any new or updated permissions being added None ### Description of how you validated changes Add both unit and integ test. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 2f9bc41 commit 9ac3084

File tree

27 files changed

+4751
-1
lines changed

27 files changed

+4751
-1
lines changed

packages/@aws-cdk/aws-redshift-alpha/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -711,3 +711,26 @@ you can set the `classicResizing` flag when creating the cluster.
711711

712712
There are other constraints to be aware of, for example, elastic resizing does not support single-node clusters and there are
713713
limits on the number of nodes you can add to a cluster. See the [AWS Redshift Documentation](https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-operations.html#rs-resize-tutorial) and [AWS API Documentation](https://docs.aws.amazon.com/redshift/latest/APIReference/API_ResizeCluster.html) for more details.
714+
715+
## Maintenance track name
716+
717+
When Amazon Redshift releases a new cluster version, your cluster is updated during its maintenance window.
718+
You can control whether your cluster is updated to the most recent approved release or to the previous release.
719+
See the [AWS Redshift Documentation](https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-considerations.html#rs-mgmt-maintenance-tracks) for more details.
720+
721+
To control which cluster version is applied during a maintenance window, set the `maintenanceTrackName` property for the cluster.
722+
723+
```ts
724+
new redshift.Cluster(stack, 'Cluster', {
725+
masterUser: {
726+
masterUsername: 'admin',
727+
},
728+
vpc,
729+
maintenanceTrackName: redshift.MaintenanceTrackName.CURRENT,
730+
});
731+
```
732+
733+
You can specify one of the following `MaintenanceTrackName` values:
734+
735+
* `CURRENT`: Use the most current approved cluster version.
736+
* `TRAILING`: Use the cluster version before the current version.

packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts

+27
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,23 @@ export interface RotationMultiUserOptions {
186186
readonly automaticallyAfter?: Duration;
187187
}
188188

189+
/**
190+
* The maintenance track for the cluster.
191+
*
192+
* @see https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-considerations.html#rs-mgmt-maintenance-tracks
193+
*/
194+
export enum MaintenanceTrackName {
195+
/**
196+
* Updated to the most recently certified maintenance release.
197+
*/
198+
CURRENT = 'current',
199+
200+
/**
201+
* Update to the previously certified maintenance release.
202+
*/
203+
TRAILING = 'trailing',
204+
}
205+
189206
/**
190207
* Create a Redshift Cluster with a given number of nodes.
191208
* Implemented by `Cluster` via `ClusterBase`.
@@ -443,6 +460,15 @@ export interface ClusterProps {
443460
* @default - false
444461
*/
445462
readonly availabilityZoneRelocation?: boolean;
463+
464+
/**
465+
* The maintenance track name for the cluster.
466+
*
467+
* @see https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-considerations.html#rs-mgmt-maintenance-tracks
468+
*
469+
* @default undefined - Redshift default is current
470+
*/
471+
readonly maintenanceTrackName?: MaintenanceTrackName;
446472
}
447473

448474
/**
@@ -640,6 +666,7 @@ export class Cluster extends ClusterBase {
640666
this.cluster = new CfnCluster(this, 'Resource', {
641667
// Basic
642668
allowVersionUpgrade: true,
669+
maintenanceTrackName: props.maintenanceTrackName,
643670
automatedSnapshotRetentionPeriod: 1,
644671
clusterType,
645672
clusterIdentifier: props.clusterName,

packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as iam from 'aws-cdk-lib/aws-iam';
44
import * as kms from 'aws-cdk-lib/aws-kms';
55
import * as s3 from 'aws-cdk-lib/aws-s3';
66
import * as cdk from 'aws-cdk-lib';
7-
import { Cluster, ClusterParameterGroup, ClusterSubnetGroup, ClusterType, NodeType, ResourceAction } from '../lib';
7+
import { Cluster, ClusterParameterGroup, ClusterSubnetGroup, ClusterType, MaintenanceTrackName, NodeType, ResourceAction } from '../lib';
88
import { CfnCluster } from 'aws-cdk-lib/aws-redshift';
99

1010
let stack: cdk.Stack;
@@ -59,6 +59,25 @@ test('check that instantiation works', () => {
5959
});
6060
});
6161

62+
test('specify maintenance track name', () => {
63+
// WHEN
64+
new Cluster(stack, 'Redshift', {
65+
masterUser: {
66+
masterUsername: 'admin',
67+
masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),
68+
},
69+
vpc,
70+
maintenanceTrackName: MaintenanceTrackName.TRAILING,
71+
});
72+
73+
// THEN
74+
Template.fromStack(stack).hasResource('AWS::Redshift::Cluster', {
75+
Properties: {
76+
MaintenanceTrackName: 'trailing',
77+
},
78+
});
79+
});
80+
6281
test('can create a cluster with imported vpc and security group', () => {
6382
// GIVEN
6483
vpc = ec2.Vpc.fromLookup(stack, 'ImportedVPC', {

packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-maintenance-track-name.js.snapshot/RedshiftMaintenanceTrackNameIntegDefaultTestDeployAssert73097553.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-maintenance-track-name.js.snapshot/RedshiftMaintenanceTrackNameIntegDefaultTestDeployAssert73097553.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk/aws-redshift-alpha/test/integ.cluster-maintenance-track-name.js.snapshot/RedshiftMaintenanceTrackNameIntegStack.assets.json

+58
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)