Skip to content

Commit d648b58

Browse files
authored
feat(cdk): add the CodeDeployLambdaAlias Update Policy. (#1346)
Fixes #1177.
1 parent 239d0d5 commit d648b58

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

packages/@aws-cdk/cdk/lib/cloudformation/resource-policy.ts

+32
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ export interface UpdatePolicy {
124124
*/
125125
autoScalingScheduledAction?: AutoScalingScheduledAction;
126126

127+
/**
128+
* To perform an AWS CodeDeploy deployment when the version changes on an AWS::Lambda::Alias resource,
129+
* use the CodeDeployLambdaAliasUpdate update policy.
130+
*/
131+
codeDeployLambdaAliasUpdate?: CodeDeployLambdaAliasUpdate;
132+
127133
/**
128134
* To modify a replication group's shards by adding or removing shards, rather than replacing the entire
129135
* AWS::ElastiCache::ReplicationGroup resource, use the UseOnlineResharding update policy.
@@ -236,3 +242,29 @@ export interface AutoScalingScheduledAction {
236242
*/
237243
ignoreUnmodifiedGroupSizeProperties?: boolean;
238244
}
245+
246+
/**
247+
* To perform an AWS CodeDeploy deployment when the version changes on an AWS::Lambda::Alias resource,
248+
* use the CodeDeployLambdaAliasUpdate update policy.
249+
*/
250+
export interface CodeDeployLambdaAliasUpdate {
251+
/**
252+
* The name of the AWS CodeDeploy application.
253+
*/
254+
applicationName: string;
255+
256+
/**
257+
* The name of the AWS CodeDeploy deployment group. This is where the traffic-shifting policy is set.
258+
*/
259+
deploymentGroupName: string;
260+
261+
/**
262+
* The name of the Lambda function to run before traffic routing starts.
263+
*/
264+
beforeAllowTrafficHook?: string;
265+
266+
/**
267+
* The name of the Lambda function to run after traffic routing completes.
268+
*/
269+
afterAllowTrafficHook?: string;
270+
}

packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,15 @@ export = {
171171

172172
r1.options.creationPolicy = { autoScalingCreationPolicy: { minSuccessfulInstancesPercent: 10 } };
173173
// tslint:disable-next-line:max-line-length
174-
r1.options.updatePolicy = { autoScalingScheduledAction: { ignoreUnmodifiedGroupSizeProperties: false }, autoScalingReplacingUpdate: { willReplace: true }};
174+
r1.options.updatePolicy = {
175+
autoScalingScheduledAction: { ignoreUnmodifiedGroupSizeProperties: false },
176+
autoScalingReplacingUpdate: { willReplace: true },
177+
codeDeployLambdaAliasUpdate: {
178+
applicationName: 'CodeDeployApplication',
179+
deploymentGroupName: 'CodeDeployDeploymentGroup',
180+
beforeAllowTrafficHook: 'lambda1',
181+
},
182+
};
175183
r1.options.deletionPolicy = DeletionPolicy.Retain;
176184

177185
test.deepEqual(stack.toCloudFormation(), {
@@ -182,6 +190,11 @@ export = {
182190
UpdatePolicy: {
183191
AutoScalingScheduledAction: { IgnoreUnmodifiedGroupSizeProperties: false },
184192
AutoScalingReplacingUpdate: { WillReplace: true },
193+
CodeDeployLambdaAliasUpdate: {
194+
ApplicationName: 'CodeDeployApplication',
195+
DeploymentGroupName: 'CodeDeployDeploymentGroup',
196+
BeforeAllowTrafficHook: 'lambda1',
197+
},
185198
},
186199
DeletionPolicy: 'Retain'
187200
}

0 commit comments

Comments
 (0)