diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts index 5932132991260..447262e1d8c1d 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/lib/shared/base-target-group.ts @@ -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), diff --git a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/test.listener.ts b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/test.listener.ts index dcf2c62c84ec1..061a578d03798 100644 --- a/packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/test.listener.ts +++ b/packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/test.listener.ts @@ -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();