From 1d04462849433cdabfcdf4c71947d8e7782db950 Mon Sep 17 00:00:00 2001 From: Blake Price Date: Tue, 9 Oct 2018 14:02:37 -0700 Subject: [PATCH 1/2] feat(cdk): Add support for UseOnlineResharding with UpdatePolicies. --- packages/@aws-cdk/cdk/lib/cloudformation/resource-policy.ts | 6 ++++++ packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/cdk/lib/cloudformation/resource-policy.ts b/packages/@aws-cdk/cdk/lib/cloudformation/resource-policy.ts index f785cb4fb76f6..a505e168cbae6 100644 --- a/packages/@aws-cdk/cdk/lib/cloudformation/resource-policy.ts +++ b/packages/@aws-cdk/cdk/lib/cloudformation/resource-policy.ts @@ -124,6 +124,12 @@ export interface UpdatePolicy { */ autoScalingScheduledAction?: AutoScalingScheduledAction; + /** + * To modify a replication group's shards by adding or removing shards, rather than replacing the entire + * AWS::ElastiCache::ReplicationGroup resource, use the UseOnlineResharding update policy. + */ + useOnlineResharding?: boolean; + } /** diff --git a/packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts b/packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts index 12cd7d61f2e6a..93db52fce7f7a 100644 --- a/packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts +++ b/packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts @@ -170,7 +170,7 @@ export = { r1.options.creationPolicy = { autoScalingCreationPolicy: { minSuccessfulInstancesPercent: 10 } }; // tslint:disable-next-line:max-line-length - r1.options.updatePolicy = { autoScalingScheduledAction: { ignoreUnmodifiedGroupSizeProperties: false }, autoScalingReplacingUpdate: { willReplace: true } }; + r1.options.updatePolicy = { autoScalingScheduledAction: { ignoreUnmodifiedGroupSizeProperties: false }, autoScalingReplacingUpdate: { willReplace: true }, useOnlineResharding: true }; r1.options.deletionPolicy = DeletionPolicy.Retain; test.deepEqual(stack.toCloudFormation(), { @@ -180,7 +180,8 @@ export = { CreationPolicy: { AutoScalingCreationPolicy: { MinSuccessfulInstancesPercent: 10 } }, UpdatePolicy: { AutoScalingScheduledAction: { IgnoreUnmodifiedGroupSizeProperties: false }, - AutoScalingReplacingUpdate: { WillReplace: true } + AutoScalingReplacingUpdate: { WillReplace: true }, + UseOnlineResharding: true, }, DeletionPolicy: 'Retain' } From 3a9e3ce0daec351467b8b225b00278000eeebb64 Mon Sep 17 00:00:00 2001 From: Blake Price Date: Tue, 9 Oct 2018 14:36:20 -0700 Subject: [PATCH 2/2] Update test to be independent --- .../cdk/test/cloudformation/test.resource.ts | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts b/packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts index 93db52fce7f7a..4c5d303c97848 100644 --- a/packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts +++ b/packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts @@ -170,7 +170,7 @@ export = { r1.options.creationPolicy = { autoScalingCreationPolicy: { minSuccessfulInstancesPercent: 10 } }; // tslint:disable-next-line:max-line-length - r1.options.updatePolicy = { autoScalingScheduledAction: { ignoreUnmodifiedGroupSizeProperties: false }, autoScalingReplacingUpdate: { willReplace: true }, useOnlineResharding: true }; + r1.options.updatePolicy = { autoScalingScheduledAction: { ignoreUnmodifiedGroupSizeProperties: false }, autoScalingReplacingUpdate: { willReplace: true }}; r1.options.deletionPolicy = DeletionPolicy.Retain; test.deepEqual(stack.toCloudFormation(), { @@ -181,7 +181,6 @@ export = { UpdatePolicy: { AutoScalingScheduledAction: { IgnoreUnmodifiedGroupSizeProperties: false }, AutoScalingReplacingUpdate: { WillReplace: true }, - UseOnlineResharding: true, }, DeletionPolicy: 'Retain' } @@ -191,6 +190,26 @@ export = { test.done(); }, + 'update policies UseOnlineResharding flag'(test: Test) { + const stack = new Stack(); + const r1 = new Resource(stack, 'Resource', { type: 'Type' }); + + r1.options.updatePolicy = { useOnlineResharding: true }; + + test.deepEqual(stack.toCloudFormation(), { + Resources: { + Resource: { + Type: 'Type', + UpdatePolicy: { + UseOnlineResharding: true, + }, + } + } + }); + + test.done(); + }, + 'metadata can be set on a resource'(test: Test) { const stack = new Stack(); const r1 = new Resource(stack, 'Resource', { type: 'Type' });