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): optionally reboot Clusters to apply parameter changes #22063

Merged
merged 25 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8b8798c
inital implementation
dontirun Sep 13, 2022
68ebe28
add lambda handler
dontirun Sep 14, 2022
f262a52
documentation, tests, and bugfixes
Sep 15, 2022
6c1122b
Merge branch 'main' into feat-reboot-cluster-for-parameter-updates
Sep 30, 2022
c61f994
Merge branch 'main' into feat-reboot-cluster-for-parameter-updates
Oct 4, 2022
6fe9387
Merge branch 'main' into feat-reboot-cluster-for-parameter-updates
Oct 10, 2022
63400f6
fix: allow for enabling the reboot feature before the parameter group…
Oct 10, 2022
a5d1ee5
test: comment out assertions
Oct 10, 2022
153345a
chore: commit deleted asstes
Oct 10, 2022
f31b6dd
chore: update snapshot
Oct 11, 2022
a01c334
Merge branch 'main' into feat-reboot-cluster-for-parameter-updates
Oct 19, 2022
52916e6
tests: regenerate snapshot
Oct 19, 2022
c445b0f
chore: commenting out diff assets in integ test
Nov 16, 2022
26fbbaa
docs: add testing procedure to integ test
Nov 16, 2022
b732dcf
Merge branch 'main' into feat-reboot-cluster-for-parameter-updates
Nov 16, 2022
692d1ab
Merge branch 'main' into feat-reboot-cluster-for-parameter-updates
Dec 9, 2022
762f2bf
test: update assertions on integ test
Dec 14, 2022
dae7883
Merge branch 'main' into feat-reboot-cluster-for-parameter-updates
dontirun Dec 16, 2022
75ebd28
Merge branch 'main' into feat-reboot-cluster-for-parameter-updates
dontirun Jan 18, 2023
b6c323d
refactor: removing unknown-error from reboot actions
dontirun Feb 14, 2023
1c69185
Merge branch 'master' into feat-reboot-cluster-for-parameter-updates
dontirun Feb 14, 2023
80848a9
Update packages/@aws-cdk/aws-redshift/lib/cluster-parameter-change-re…
dontirun Feb 14, 2023
f91ffeb
refactor: use guard clause for clarity
Feb 16, 2023
a76b887
refactor: update guard clause
Feb 17, 2023
16ba85f
Merge branch 'main' into feat-reboot-cluster-for-parameter-updates
mergify[bot] Feb 17, 2023
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
Prev Previous commit
Next Next commit
refactor: update guard clause
  • Loading branch information
Arun Donti committed Feb 17, 2023
commit a76b88763c2cad732b3080184651a1718cdeb429
10 changes: 2 additions & 8 deletions packages/@aws-cdk/aws-redshift/lib/cluster.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as path from 'path';
import * as ec2 from '@aws-cdk/aws-ec2';
import * as iam from '@aws-cdk/aws-iam';
import * as kms from '@aws-cdk/aws-kms';
Expand All @@ -7,7 +8,6 @@ import * as secretsmanager from '@aws-cdk/aws-secretsmanager';
import { ArnFormat, CustomResource, Duration, IResource, Lazy, RemovalPolicy, Resource, SecretValue, Stack, Token } from '@aws-cdk/core';
import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId, Provider } from '@aws-cdk/custom-resources';
import { Construct } from 'constructs';
import * as path from 'path';
import { DatabaseSecret } from './database-secret';
import { Endpoint } from './endpoint';
import { ClusterParameterGroup, IClusterParameterGroup } from './parameter-group';
Expand Down Expand Up @@ -477,11 +477,6 @@ export class Cluster extends ClusterBase {
*/
protected parameterGroup?: IClusterParameterGroup;

/**
* Guards against repeated invocations of enableRebootForParameterChanges()
*/
protected rebootForParameterChangesEnabled?: boolean;

/**
* The ARNs of the roles that will be attached to the cluster.
*
Expand Down Expand Up @@ -707,10 +702,9 @@ export class Cluster extends ClusterBase {
* Enables automatic cluster rebooting when changes to the cluster's parameter group require a restart to apply.
*/
public enableRebootForParameterChanges(): void {
if (this.rebootForParameterChangesEnabled) {
if (this.node.tryFindChild('RedshiftClusterRebooterCustomResource')) {
return;
}
this.rebootForParameterChangesEnabled = true;
const rebootFunction = new lambda.SingletonFunction(this, 'RedshiftClusterRebooterFunction', {
uuid: '511e207f-13df-4b8b-b632-c32b30b65ac2',
runtime: lambda.Runtime.NODEJS_16_X,
Expand Down
16 changes: 16 additions & 0 deletions packages/@aws-cdk/aws-redshift/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,22 @@ describe('reboot for Parameter Changes', () => {
.not.toThrowError(/Cannot enable reboot for parameter changes/);
});

test('not create duplicate resources when reboot feature is enabled multiple times on a cluster', () => {
// Given
const cluster = new Cluster(stack, 'Redshift', {
masterUser: {
masterUsername: 'admin',
},
vpc,
rebootForParameterChanges: true,
});
cluster.addToParameterGroup('foo', 'bar');
//WHEN
cluster.enableRebootForParameterChanges();
// THEN
Template.fromStack(stack).resourceCountIs('Custom::RedshiftClusterRebooter', 1);
});

test('cluster with parameter group', () => {
// Given
const cluster = new Cluster(stack, 'Redshift', {
Expand Down