diff --git a/src/constructs/loadbalancing/alb/application-target-group.test.ts b/src/constructs/loadbalancing/alb/application-target-group.test.ts index b695c1dac..5bad689d9 100644 --- a/src/constructs/loadbalancing/alb/application-target-group.test.ts +++ b/src/constructs/loadbalancing/alb/application-target-group.test.ts @@ -3,8 +3,9 @@ import "../../../utils/test/jest"; import { SynthUtils } from "@aws-cdk/assert"; import { Vpc } from "@aws-cdk/aws-ec2"; import { Stack } from "@aws-cdk/core"; +import { TrackingTag } from "../../../constants/library-info"; import type { SynthedStack } from "../../../utils/test"; -import { simpleGuStackForTesting } from "../../../utils/test"; +import { alphabeticalTags, simpleGuStackForTesting } from "../../../utils/test"; import type { AppIdentity } from "../../core/identity"; import { GuApplicationTargetGroup } from "./application-target-group"; @@ -29,6 +30,28 @@ describe("The GuApplicationTargetGroup class", () => { ); }); + it("should apply the App tag", () => { + const stack = simpleGuStackForTesting(); + new GuApplicationTargetGroup(stack, "ApplicationTargetGroup", { ...app, vpc }); + + expect(stack).toHaveResource("AWS::ElasticLoadBalancingV2::TargetGroup", { + Tags: alphabeticalTags([ + { Key: "App", Value: app.app }, + { + Key: "Stack", + Value: stack.stack, + }, + { + Key: "Stage", + Value: { + Ref: "Stage", + }, + }, + TrackingTag, + ]), + }); + }); + test("overrides the id if the prop is true", () => { const stack = simpleGuStackForTesting(); new GuApplicationTargetGroup(stack, "ApplicationTargetGroup", { ...app, vpc, overrideId: true }); diff --git a/src/constructs/loadbalancing/alb/application-target-group.ts b/src/constructs/loadbalancing/alb/application-target-group.ts index 849fd2edd..919ac10c5 100644 --- a/src/constructs/loadbalancing/alb/application-target-group.ts +++ b/src/constructs/loadbalancing/alb/application-target-group.ts @@ -30,5 +30,7 @@ export class GuApplicationTargetGroup extends ApplicationTargetGroup { if (mergedProps.overrideId || (scope.migratedFromCloudFormation && mergedProps.overrideId !== false)) (this.node.defaultChild as CfnTargetGroup).overrideLogicalId(id); + + AppIdentity.taggedConstruct({ app }, this); } }