From 56f0b4e0985bf75e05ccb2d5159d6c3dd932f408 Mon Sep 17 00:00:00 2001 From: ZeldoKavira Date: Tue, 9 Oct 2018 21:20:56 -0700 Subject: [PATCH] feat(cdk): Add support for UseOnlineResharding with UpdatePolicies (#881) --- .../cdk/lib/cloudformation/resource-policy.ts | 6 +++++ .../cdk/test/cloudformation/test.resource.ts | 24 +++++++++++++++++-- 2 files changed, 28 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..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 } }; + r1.options.updatePolicy = { autoScalingScheduledAction: { ignoreUnmodifiedGroupSizeProperties: false }, autoScalingReplacingUpdate: { willReplace: true }}; r1.options.deletionPolicy = DeletionPolicy.Retain; test.deepEqual(stack.toCloudFormation(), { @@ -180,7 +180,7 @@ export = { CreationPolicy: { AutoScalingCreationPolicy: { MinSuccessfulInstancesPercent: 10 } }, UpdatePolicy: { AutoScalingScheduledAction: { IgnoreUnmodifiedGroupSizeProperties: false }, - AutoScalingReplacingUpdate: { WillReplace: true } + AutoScalingReplacingUpdate: { WillReplace: true }, }, DeletionPolicy: 'Retain' } @@ -190,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' });