Skip to content

Commit 05a49f0

Browse files
skinny85Elad Ben-Israel
authored andcommitted
feat(codedeploy): allow setting a Deployment Configuration for an imported Lambda Deployment Group. (#3158)
1 parent bd46e49 commit 05a49f0

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

packages/@aws-cdk/aws-codedeploy/lib/lambda/deployment-group.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ export interface ILambdaDeploymentGroup extends cdk.IResource {
2929
* @attribute
3030
*/
3131
readonly deploymentGroupArn: string;
32+
33+
/**
34+
* The Deployment Configuration this Group uses.
35+
*/
36+
readonly deploymentConfig: ILambdaDeploymentConfig;
3237
}
3338

3439
/**
@@ -52,7 +57,7 @@ export interface LambdaDeploymentGroupProps {
5257
/**
5358
* The Deployment Configuration this Deployment Group uses.
5459
*
55-
* @default LambdaDeploymentConfig#AllAtOnce
60+
* @default LambdaDeploymentConfig.CANARY_10PERCENT_5MINUTES
5661
*/
5762
readonly deploymentConfig?: ILambdaDeploymentConfig;
5863

@@ -135,6 +140,7 @@ export class LambdaDeploymentGroup extends cdk.Resource implements ILambdaDeploy
135140
public readonly application: ILambdaApplication;
136141
public readonly deploymentGroupName: string;
137142
public readonly deploymentGroupArn: string;
143+
public readonly deploymentConfig: ILambdaDeploymentConfig;
138144
public readonly role: iam.IRole;
139145

140146
private readonly alarms: cloudwatch.IAlarm[];
@@ -154,12 +160,13 @@ export class LambdaDeploymentGroup extends cdk.Resource implements ILambdaDeploy
154160
});
155161

156162
this.role.addManagedPolicy(iam.ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSCodeDeployRoleForLambda'));
163+
this.deploymentConfig = props.deploymentConfig || LambdaDeploymentConfig.CANARY_10PERCENT_5MINUTES;
157164

158165
const resource = new CfnDeploymentGroup(this, 'Resource', {
159166
applicationName: this.application.applicationName,
160167
serviceRoleArn: this.role.roleArn,
161168
deploymentGroupName: this.physicalName,
162-
deploymentConfigName: (props.deploymentConfig || LambdaDeploymentConfig.ALL_AT_ONCE).deploymentConfigName,
169+
deploymentConfigName: this.deploymentConfig.deploymentConfigName,
163170
deploymentStyle: {
164171
deploymentType: 'BLUE_GREEN',
165172
deploymentOption: 'WITH_TRAFFIC_CONTROL'
@@ -262,17 +269,26 @@ export interface LambdaDeploymentGroupAttributes {
262269
* that we are referencing.
263270
*/
264271
readonly deploymentGroupName: string;
272+
273+
/**
274+
* The Deployment Configuration this Deployment Group uses.
275+
*
276+
* @default LambdaDeploymentConfig.CANARY_10PERCENT_5MINUTES
277+
*/
278+
readonly deploymentConfig?: ILambdaDeploymentConfig;
265279
}
266280

267281
class ImportedLambdaDeploymentGroup extends cdk.Resource implements ILambdaDeploymentGroup {
268282
public readonly application: ILambdaApplication;
269283
public readonly deploymentGroupName: string;
270284
public readonly deploymentGroupArn: string;
285+
public readonly deploymentConfig: ILambdaDeploymentConfig;
271286

272287
constructor(scope: cdk.Construct, id: string, props: LambdaDeploymentGroupAttributes) {
273288
super(scope, id);
274289
this.application = props.application;
275290
this.deploymentGroupName = props.deploymentGroupName;
276291
this.deploymentGroupArn = arnForDeploymentGroup(props.application.applicationName, props.deploymentGroupName);
292+
this.deploymentConfig = props.deploymentConfig || LambdaDeploymentConfig.CANARY_10PERCENT_5MINUTES;
277293
}
278294
}

packages/@aws-cdk/aws-codedeploy/test/lambda/test.deployment-group.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,5 +581,21 @@ export = {
581581

582582
test.done();
583583
},
584-
}
584+
585+
'imported with fromLambdaDeploymentGroupAttributes': {
586+
'defaults the Deployment Config to Canary10Percent5Minutes'(test: Test) {
587+
const stack = new cdk.Stack();
588+
589+
const lambdaApp = codedeploy.LambdaApplication.fromLambdaApplicationName(stack, 'LA', 'LambdaApplication');
590+
const importedGroup = codedeploy.LambdaDeploymentGroup.fromLambdaDeploymentGroupAttributes(stack, 'LDG', {
591+
application: lambdaApp,
592+
deploymentGroupName: 'LambdaDeploymentGroup',
593+
});
594+
595+
test.equal(importedGroup.deploymentConfig, LambdaDeploymentConfig.CANARY_10PERCENT_5MINUTES);
596+
597+
test.done();
598+
},
599+
},
600+
},
585601
};

0 commit comments

Comments
 (0)