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-alpha): maintenance track name #33552

Merged
merged 7 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
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