Skip to content

Commit 9d228e4

Browse files
authored
fix(codedeploy): DeploymentGroup's physical name not propagated to Application (#13582)
fixes #13337 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 0ec7a1b commit 9d228e4

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupBase {
269269
physicalName: props.deploymentGroupName,
270270
});
271271

272-
this.application = props.application || new ServerApplication(this, 'Application');
272+
this.application = props.application || new ServerApplication(this, 'Application', {
273+
applicationName: props.deploymentGroupName === cdk.PhysicalName.GENERATE_IF_NEEDED ? cdk.PhysicalName.GENERATE_IF_NEEDED : undefined,
274+
});
273275

274276
this.role = props.role || new iam.Role(this, 'Role', {
275277
assumedBy: new iam.ServicePrincipal('codedeploy.amazonaws.com'),

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expect, haveResource, SynthUtils } from '@aws-cdk/assert';
1+
import { expect, haveOutput, haveResource, SynthUtils } from '@aws-cdk/assert';
22
import * as autoscaling from '@aws-cdk/aws-autoscaling';
33
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
44
import * as ec2 from '@aws-cdk/aws-ec2';
@@ -28,6 +28,25 @@ export = {
2828
test.done();
2929
},
3030

31+
'creating an application with physical name if needed'(test: Test) {
32+
const stack = new cdk.Stack(undefined, undefined, { env: { account: '12345', region: 'us-test-1' } });
33+
const stack2 = new cdk.Stack(undefined, undefined, { env: { account: '12346', region: 'us-test-2' } });
34+
const serverDeploymentGroup = new codedeploy.ServerDeploymentGroup(stack, 'MyDG', {
35+
deploymentGroupName: cdk.PhysicalName.GENERATE_IF_NEEDED,
36+
});
37+
38+
new cdk.CfnOutput(stack2, 'Output', {
39+
value: serverDeploymentGroup.application.applicationName,
40+
});
41+
42+
expect(stack2).to(haveOutput({
43+
outputName: 'Output',
44+
outputValue: 'defaultmydgapplication78dba0bb0c7580b32033',
45+
}));
46+
47+
test.done();
48+
},
49+
3150
'can be imported'(test: Test) {
3251
const stack = new cdk.Stack();
3352

0 commit comments

Comments
 (0)