Skip to content

Commit

Permalink
fix: Apply App tag to GuApplicationTargetGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
akash1810 committed Apr 9, 2021
1 parent a1cf249 commit cfab666
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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 });
Expand Down
2 changes: 2 additions & 0 deletions src/constructs/loadbalancing/alb/application-target-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit cfab666

Please sign in to comment.