Skip to content

Commit

Permalink
fix(codedeploy): DeploymentGroup's physical name not propagated to A…
Browse files Browse the repository at this point in the history
…pplication (aws#13582)

fixes aws#13337


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
BLasan authored and hollanddd committed Aug 26, 2021
1 parent f1bf289 commit 097bf5e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupBase {
physicalName: props.deploymentGroupName,
});

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

this.role = props.role || new iam.Role(this, 'Role', {
assumedBy: new iam.ServicePrincipal('codedeploy.amazonaws.com'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, haveResource, SynthUtils } from '@aws-cdk/assert';
import { expect, haveOutput, haveResource, SynthUtils } from '@aws-cdk/assert';
import * as autoscaling from '@aws-cdk/aws-autoscaling';
import * as cloudwatch from '@aws-cdk/aws-cloudwatch';
import * as ec2 from '@aws-cdk/aws-ec2';
Expand Down Expand Up @@ -28,6 +28,25 @@ export = {
test.done();
},

'creating an application with physical name if needed'(test: Test) {
const stack = new cdk.Stack(undefined, undefined, { env: { account: '12345', region: 'us-test-1' } });
const stack2 = new cdk.Stack(undefined, undefined, { env: { account: '12346', region: 'us-test-2' } });
const serverDeploymentGroup = new codedeploy.ServerDeploymentGroup(stack, 'MyDG', {
deploymentGroupName: cdk.PhysicalName.GENERATE_IF_NEEDED,
});

new cdk.CfnOutput(stack2, 'Output', {
value: serverDeploymentGroup.application.applicationName,
});

expect(stack2).to(haveOutput({
outputName: 'Output',
outputValue: 'defaultmydgapplication78dba0bb0c7580b32033',
}));

test.done();
},

'can be imported'(test: Test) {
const stack = new cdk.Stack();

Expand Down

0 comments on commit 097bf5e

Please sign in to comment.