Skip to content

Commit

Permalink
fix(elbv2): fix specifying TargetGroup name (#1684)
Browse files Browse the repository at this point in the history
TargetGroup construct passes targetGroupName prop to underlying
CfnTargetGroup, but the correct name is Name, not TargetGroupName.

Fixes #1674
  • Loading branch information
motemen authored and rix0rrr committed Feb 6, 2019
1 parent bfa40b1 commit 1d7198a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export abstract class TargetGroupBase extends cdk.Construct implements ITargetGr
this.targetType = baseProps.targetType;

this.resource = new CfnTargetGroup(this, 'Resource', {
targetGroupName: baseProps.targetGroupName,
name: baseProps.targetGroupName,
targetGroupAttributes: new cdk.Token(() => renderAttributes(this.attributes)),
targetType: new cdk.Token(() => this.targetType),
targets: new cdk.Token(() => this.targetsJson),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@ export = {
test.done();
},

'Can configure name on TargetGroups'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'Stack');

// WHEN
new elbv2.ApplicationTargetGroup(stack, 'TargetGroup', {
vpc,
port: 80,
targetGroupName: 'foo'
});

// THEN
expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::TargetGroup', {
Name: 'foo'
}));

test.done();
},

'Can add target groups with and without conditions'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
Expand Down

0 comments on commit 1d7198a

Please sign in to comment.