diff --git a/packages/@aws-cdk/aws-codedeploy/lib/lambda/deployment-group.ts b/packages/@aws-cdk/aws-codedeploy/lib/lambda/deployment-group.ts index 0fcddbb7526ee..59dc7192e5d41 100644 --- a/packages/@aws-cdk/aws-codedeploy/lib/lambda/deployment-group.ts +++ b/packages/@aws-cdk/aws-codedeploy/lib/lambda/deployment-group.ts @@ -29,6 +29,11 @@ export interface ILambdaDeploymentGroup extends cdk.IResource { * @attribute */ readonly deploymentGroupArn: string; + + /** + * The Deployment Configuration this Group uses. + */ + readonly deploymentConfig: ILambdaDeploymentConfig; } /** @@ -135,6 +140,7 @@ export class LambdaDeploymentGroup extends cdk.Resource implements ILambdaDeploy public readonly application: ILambdaApplication; public readonly deploymentGroupName: string; public readonly deploymentGroupArn: string; + public readonly deploymentConfig: ILambdaDeploymentConfig; public readonly role: iam.IRole; private readonly alarms: cloudwatch.IAlarm[]; @@ -154,12 +160,13 @@ export class LambdaDeploymentGroup extends cdk.Resource implements ILambdaDeploy }); this.role.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSCodeDeployRoleForLambda')); + this.deploymentConfig = props.deploymentConfig || LambdaDeploymentConfig.ALL_AT_ONCE; const resource = new CfnDeploymentGroup(this, 'Resource', { applicationName: this.application.applicationName, serviceRoleArn: this.role.roleArn, deploymentGroupName: this.physicalName, - deploymentConfigName: (props.deploymentConfig || LambdaDeploymentConfig.ALL_AT_ONCE).deploymentConfigName, + deploymentConfigName: this.deploymentConfig.deploymentConfigName, deploymentStyle: { deploymentType: 'BLUE_GREEN', deploymentOption: 'WITH_TRAFFIC_CONTROL' @@ -262,17 +269,26 @@ export interface LambdaDeploymentGroupAttributes { * that we are referencing. */ readonly deploymentGroupName: string; + + /** + * The Deployment Configuration this Deployment Group uses. + * + * @default LambdaDeploymentConfig.ALL_AT_ONCE + */ + readonly deploymentConfig?: ILambdaDeploymentConfig; } class ImportedLambdaDeploymentGroup extends cdk.Resource implements ILambdaDeploymentGroup { public readonly application: ILambdaApplication; public readonly deploymentGroupName: string; public readonly deploymentGroupArn: string; + public readonly deploymentConfig: ILambdaDeploymentConfig; constructor(scope: cdk.Construct, id: string, props: LambdaDeploymentGroupAttributes) { super(scope, id); this.application = props.application; this.deploymentGroupName = props.deploymentGroupName; this.deploymentGroupArn = arnForDeploymentGroup(props.application.applicationName, props.deploymentGroupName); + this.deploymentConfig = props.deploymentConfig || LambdaDeploymentConfig.ALL_AT_ONCE; } } diff --git a/packages/@aws-cdk/aws-codedeploy/test/lambda/test.deployment-group.ts b/packages/@aws-cdk/aws-codedeploy/test/lambda/test.deployment-group.ts index a9095766e7e34..78ec4866ed482 100644 --- a/packages/@aws-cdk/aws-codedeploy/test/lambda/test.deployment-group.ts +++ b/packages/@aws-cdk/aws-codedeploy/test/lambda/test.deployment-group.ts @@ -581,5 +581,21 @@ export = { test.done(); }, - } + + 'imported with fromLambdaDeploymentGroupAttributes': { + 'defaults the Deployment Config to ALL_AT_ONCE'(test: Test) { + const stack = new cdk.Stack(); + + const lambdaApp = codedeploy.LambdaApplication.fromLambdaApplicationName(stack, 'LA', 'LambdaApplication'); + const importedGroup = codedeploy.LambdaDeploymentGroup.fromLambdaDeploymentGroupAttributes(stack, 'LDG', { + application: lambdaApp, + deploymentGroupName: 'LambdaDeploymentGroup', + }); + + test.equal(importedGroup.deploymentConfig, LambdaDeploymentConfig.ALL_AT_ONCE); + + test.done(); + }, + }, + }, };