Skip to content

Commit

Permalink
feat(cdk): Add support for UseOnlineResharding with UpdatePolicies (#881
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ZeldoKavira authored and Elad Ben-Israel committed Oct 10, 2018
1 parent bba3602 commit 56f0b4e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
6 changes: 6 additions & 0 deletions packages/@aws-cdk/cdk/lib/cloudformation/resource-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

/**
Expand Down
24 changes: 22 additions & 2 deletions packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(), {
Expand All @@ -180,7 +180,7 @@ export = {
CreationPolicy: { AutoScalingCreationPolicy: { MinSuccessfulInstancesPercent: 10 } },
UpdatePolicy: {
AutoScalingScheduledAction: { IgnoreUnmodifiedGroupSizeProperties: false },
AutoScalingReplacingUpdate: { WillReplace: true }
AutoScalingReplacingUpdate: { WillReplace: true },
},
DeletionPolicy: 'Retain'
}
Expand All @@ -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' });
Expand Down

0 comments on commit 56f0b4e

Please sign in to comment.