Skip to content

Commit

Permalink
fix(elbv2): use correct prop for TargetGroup name
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 aws#1674
  • Loading branch information
motemen committed Feb 6, 2019
1 parent bfa40b1 commit 26fc74c
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 26fc74c

Please sign in to comment.