diff --git a/packages/@aws-cdk/cdk/lib/cloudformation/resource-policy.ts b/packages/@aws-cdk/cdk/lib/cloudformation/resource-policy.ts index a505e168cbae6..a7dcf67986cc3 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 perform an AWS CodeDeploy deployment when the version changes on an AWS::Lambda::Alias resource, + * use the CodeDeployLambdaAliasUpdate update policy. + */ + codeDeployLambdaAliasUpdate?: CodeDeployLambdaAliasUpdate; + /** * 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. @@ -236,3 +242,29 @@ export interface AutoScalingScheduledAction { */ ignoreUnmodifiedGroupSizeProperties?: boolean; } + +/** + * To perform an AWS CodeDeploy deployment when the version changes on an AWS::Lambda::Alias resource, + * use the CodeDeployLambdaAliasUpdate update policy. + */ +export interface CodeDeployLambdaAliasUpdate { + /** + * The name of the AWS CodeDeploy application. + */ + applicationName: string; + + /** + * The name of the AWS CodeDeploy deployment group. This is where the traffic-shifting policy is set. + */ + deploymentGroupName: string; + + /** + * The name of the Lambda function to run before traffic routing starts. + */ + beforeAllowTrafficHook?: string; + + /** + * The name of the Lambda function to run after traffic routing completes. + */ + afterAllowTrafficHook?: string; +} diff --git a/packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts b/packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts index b1bd59e016b77..9b961a4de0cd4 100644 --- a/packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts +++ b/packages/@aws-cdk/cdk/test/cloudformation/test.resource.ts @@ -171,7 +171,15 @@ 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 }, + codeDeployLambdaAliasUpdate: { + applicationName: 'CodeDeployApplication', + deploymentGroupName: 'CodeDeployDeploymentGroup', + beforeAllowTrafficHook: 'lambda1', + }, + }; r1.options.deletionPolicy = DeletionPolicy.Retain; test.deepEqual(stack.toCloudFormation(), { @@ -182,6 +190,11 @@ export = { UpdatePolicy: { AutoScalingScheduledAction: { IgnoreUnmodifiedGroupSizeProperties: false }, AutoScalingReplacingUpdate: { WillReplace: true }, + CodeDeployLambdaAliasUpdate: { + ApplicationName: 'CodeDeployApplication', + DeploymentGroupName: 'CodeDeployDeploymentGroup', + BeforeAllowTrafficHook: 'lambda1', + }, }, DeletionPolicy: 'Retain' }