aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

fix (elbv2): Use correct format for parsing imported target group ARNs

Open clareliguori opened this issue 3 years ago • 7 comments

Currently, the following CDK snippet results in outputting the target group ID, not the target group name.

    const importedTgArn = cdk.Fn.importValue('ImportTargetGroupArn');
    const importedTg = elbv2.ApplicationTargetGroup.fromTargetGroupAttributes(stack, 'ImportedTg', {
      targetGroupArn: importedTgArn,
    });
    new cdk.CfnOutput(stack, 'TargetGroupOutput', {
      value: importedTg.targetGroupName,
    });

For example, for a sample target group ARN:

arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/MyTargetGroupName/6a58f7d61e2151d4

The stack above will output 6a58f7d61e2151d4 instead of the desired MyTargetGroupName.

This change fixes the ARN format used for parsing the imported ARN value. It does not impact any existing CDK code passing a raw ARN string (as confirmed by existing unit tests), only CDK code trying to pass tokens such as import values.


All Submissions:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

clareliguori avatar Sep 20 '22 19:09 clareliguori

gitpod-io[bot] avatar Sep 20 '22 19:09 gitpod-io[bot]

FYI - Ignore the PR Linter right now.

TheRealAmazonKendra avatar Sep 20 '22 20:09 TheRealAmazonKendra

@Mergifyio update

TheRealAmazonKendra avatar Sep 20 '22 20:09 TheRealAmazonKendra

update

✅ Branch has been successfully updated

mergify[bot] avatar Sep 20 '22 20:09 mergify[bot]

@Mergifyio update

corymhall avatar Sep 21 '22 12:09 corymhall

update

✅ Branch has been successfully updated

mergify[bot] avatar Sep 21 '22 12:09 mergify[bot]

@Mergifyio update

corymhall avatar Sep 23 '22 13:09 corymhall

update

✅ Branch has been successfully updated

mergify[bot] avatar Sep 23 '22 13:09 mergify[bot]

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

mergify[bot] avatar Sep 23 '22 13:09 mergify[bot]

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: d1442ffb5be33ce5125845ec2cd9d36e73f2796e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

aws-cdk-automation avatar Sep 23 '22 15:09 aws-cdk-automation

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

mergify[bot] avatar Sep 23 '22 15:09 mergify[bot]