Skip to content

Commit

Permalink
feat(redshift-alpha): maintenance track name (#33552)
Browse files Browse the repository at this point in the history
### 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*
  • Loading branch information
badmintoncryer authored Feb 25, 2025
1 parent 2f9bc41 commit 9ac3084
Show file tree
Hide file tree
Showing 27 changed files with 4,751 additions and 1 deletion.
23 changes: 23 additions & 0 deletions packages/@aws-cdk/aws-redshift-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -711,3 +711,26 @@ you can set the `classicResizing` flag when creating the cluster.

There are other constraints to be aware of, for example, elastic resizing does not support single-node clusters and there are
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.

## Maintenance track name

When Amazon Redshift releases a new cluster version, your cluster is updated during its maintenance window.
You can control whether your cluster is updated to the most recent approved release or to the previous release.
See the [AWS Redshift Documentation](https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-considerations.html#rs-mgmt-maintenance-tracks) for more details.

To control which cluster version is applied during a maintenance window, set the `maintenanceTrackName` property for the cluster.

```ts
new redshift.Cluster(stack, 'Cluster', {
masterUser: {
masterUsername: 'admin',
},
vpc,
maintenanceTrackName: redshift.MaintenanceTrackName.CURRENT,
});
```

You can specify one of the following `MaintenanceTrackName` values:

* `CURRENT`: Use the most current approved cluster version.
* `TRAILING`: Use the cluster version before the current version.
27 changes: 27 additions & 0 deletions packages/@aws-cdk/aws-redshift-alpha/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,23 @@ export interface RotationMultiUserOptions {
readonly automaticallyAfter?: Duration;
}

/**
* The maintenance track for the cluster.
*
* @see https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-considerations.html#rs-mgmt-maintenance-tracks
*/
export enum MaintenanceTrackName {
/**
* Updated to the most recently certified maintenance release.
*/
CURRENT = 'current',

/**
* Update to the previously certified maintenance release.
*/
TRAILING = 'trailing',
}

/**
* Create a Redshift Cluster with a given number of nodes.
* Implemented by `Cluster` via `ClusterBase`.
Expand Down Expand Up @@ -443,6 +460,15 @@ export interface ClusterProps {
* @default - false
*/
readonly availabilityZoneRelocation?: boolean;

/**
* The maintenance track name for the cluster.
*
* @see https://docs.aws.amazon.com/redshift/latest/mgmt/managing-cluster-considerations.html#rs-mgmt-maintenance-tracks
*
* @default undefined - Redshift default is current
*/
readonly maintenanceTrackName?: MaintenanceTrackName;
}

/**
Expand Down Expand Up @@ -640,6 +666,7 @@ export class Cluster extends ClusterBase {
this.cluster = new CfnCluster(this, 'Resource', {
// Basic
allowVersionUpgrade: true,
maintenanceTrackName: props.maintenanceTrackName,
automatedSnapshotRetentionPeriod: 1,
clusterType,
clusterIdentifier: props.clusterName,
Expand Down
21 changes: 20 additions & 1 deletion packages/@aws-cdk/aws-redshift-alpha/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as iam from 'aws-cdk-lib/aws-iam';
import * as kms from 'aws-cdk-lib/aws-kms';
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as cdk from 'aws-cdk-lib';
import { Cluster, ClusterParameterGroup, ClusterSubnetGroup, ClusterType, NodeType, ResourceAction } from '../lib';
import { Cluster, ClusterParameterGroup, ClusterSubnetGroup, ClusterType, MaintenanceTrackName, NodeType, ResourceAction } from '../lib';
import { CfnCluster } from 'aws-cdk-lib/aws-redshift';

let stack: cdk.Stack;
Expand Down Expand Up @@ -59,6 +59,25 @@ test('check that instantiation works', () => {
});
});

test('specify maintenance track name', () => {
// WHEN
new Cluster(stack, 'Redshift', {
masterUser: {
masterUsername: 'admin',
masterPassword: cdk.SecretValue.unsafePlainText('tooshort'),
},
vpc,
maintenanceTrackName: MaintenanceTrackName.TRAILING,
});

// THEN
Template.fromStack(stack).hasResource('AWS::Redshift::Cluster', {
Properties: {
MaintenanceTrackName: 'trailing',
},
});
});

test('can create a cluster with imported vpc and security group', () => {
// GIVEN
vpc = ec2.Vpc.fromLookup(stack, 'ImportedVPC', {
Expand Down

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

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

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

Loading

0 comments on commit 9ac3084

Please sign in to comment.