Skip to content

Commit 1d7198a

Browse files
motemenrix0rrr
authored andcommitted
fix(elbv2): fix specifying TargetGroup name (#1684)
TargetGroup construct passes targetGroupName prop to underlying CfnTargetGroup, but the correct name is Name, not TargetGroupName. Fixes #1674
1 parent bfa40b1 commit 1d7198a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export abstract class TargetGroupBase extends cdk.Construct implements ITargetGr
213213
this.targetType = baseProps.targetType;
214214

215215
this.resource = new CfnTargetGroup(this, 'Resource', {
216-
targetGroupName: baseProps.targetGroupName,
216+
name: baseProps.targetGroupName,
217217
targetGroupAttributes: new cdk.Token(() => renderAttributes(this.attributes)),
218218
targetType: new cdk.Token(() => this.targetType),
219219
targets: new cdk.Token(() => this.targetsJson),

packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/test.listener.ts

+20
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,26 @@ export = {
114114
test.done();
115115
},
116116

117+
'Can configure name on TargetGroups'(test: Test) {
118+
// GIVEN
119+
const stack = new cdk.Stack();
120+
const vpc = new ec2.VpcNetwork(stack, 'Stack');
121+
122+
// WHEN
123+
new elbv2.ApplicationTargetGroup(stack, 'TargetGroup', {
124+
vpc,
125+
port: 80,
126+
targetGroupName: 'foo'
127+
});
128+
129+
// THEN
130+
expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::TargetGroup', {
131+
Name: 'foo'
132+
}));
133+
134+
test.done();
135+
},
136+
117137
'Can add target groups with and without conditions'(test: Test) {
118138
// GIVEN
119139
const stack = new cdk.Stack();

0 commit comments

Comments
 (0)