diff --git a/src/constants/library-info.ts b/src/constants/library-info.ts new file mode 100644 index 0000000000..1a45f3500f --- /dev/null +++ b/src/constants/library-info.ts @@ -0,0 +1,10 @@ +import { version } from "../../package.json"; + +export const LibraryInfo = { + VERSION: version, +}; + +export const TrackingTag = { + Key: "X-Gu-CDK-Version", + Value: LibraryInfo.VERSION, +}; diff --git a/src/constructs/cloudwatch/__snapshots__/lambda-alarms.test.ts.snap b/src/constructs/cloudwatch/__snapshots__/lambda-alarms.test.ts.snap index 67793394d5..16ecf7282f 100644 --- a/src/constructs/cloudwatch/__snapshots__/lambda-alarms.test.ts.snap +++ b/src/constructs/cloudwatch/__snapshots__/lambda-alarms.test.ts.snap @@ -55,6 +55,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], "Timeout": 30, }, @@ -105,6 +109,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::IAM::Role", diff --git a/src/constructs/core/stack.test.ts b/src/constructs/core/stack.test.ts index 5fea24753a..fea9c49b1f 100644 --- a/src/constructs/core/stack.test.ts +++ b/src/constructs/core/stack.test.ts @@ -3,9 +3,10 @@ import "@aws-cdk/assert/jest"; import { SynthUtils } from "@aws-cdk/assert"; import { Role, ServicePrincipal } from "@aws-cdk/aws-iam"; import { App } from "@aws-cdk/core"; -import { simpleGuStackForTesting } from "../../../test/utils/simple-gu-stack"; -import type { SynthedStack } from "../../../test/utils/synthed-stack"; +import { simpleGuStackForTesting } from "../../../test/utils"; +import type { SynthedStack } from "../../../test/utils"; import { Stage, Stages } from "../../constants"; +import { TrackingTag } from "../../constants/library-info"; import { GuStack } from "./stack"; describe("The GuStack construct", () => { @@ -54,6 +55,7 @@ describe("The GuStack construct", () => { Ref: "Stage", }, }, + TrackingTag, ], }); }); diff --git a/src/constructs/core/stack.ts b/src/constructs/core/stack.ts index 896f026b76..6891e7a552 100644 --- a/src/constructs/core/stack.ts +++ b/src/constructs/core/stack.ts @@ -1,5 +1,6 @@ import type { App, StackProps } from "@aws-cdk/core"; import { Stack, Tags } from "@aws-cdk/core"; +import { TrackingTag } from "../../constants/library-info"; import { GuStackParameter, GuStageParameter } from "./parameters"; export interface GuStackProps extends StackProps { @@ -42,6 +43,8 @@ export class GuStack extends Stack { this._stack = new GuStackParameter(this); this._app = props.app; + this.addTag(TrackingTag.Key, TrackingTag.Value); + this.addTag("Stack", this.stack); this.addTag("Stage", this.stage); this.addTag("App", props.app); diff --git a/src/constructs/iam/policies/__snapshots__/ses.test.ts.snap b/src/constructs/iam/policies/__snapshots__/ses.test.ts.snap index 87f8f0aae3..46bec0962f 100644 --- a/src/constructs/iam/policies/__snapshots__/ses.test.ts.snap +++ b/src/constructs/iam/policies/__snapshots__/ses.test.ts.snap @@ -104,6 +104,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::IAM::Role", diff --git a/src/constructs/iam/roles/__snapshots__/instance-role.test.ts.snap b/src/constructs/iam/roles/__snapshots__/instance-role.test.ts.snap index c3440faa49..5f47d89d58 100644 --- a/src/constructs/iam/roles/__snapshots__/instance-role.test.ts.snap +++ b/src/constructs/iam/roles/__snapshots__/instance-role.test.ts.snap @@ -145,6 +145,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::IAM::Role", @@ -404,6 +408,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::IAM::Role", @@ -616,6 +624,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::IAM::Role", diff --git a/src/constructs/lambda/__snapshots__/lambda.test.ts.snap b/src/constructs/lambda/__snapshots__/lambda.test.ts.snap index 15170802ff..b19d298e82 100644 --- a/src/constructs/lambda/__snapshots__/lambda.test.ts.snap +++ b/src/constructs/lambda/__snapshots__/lambda.test.ts.snap @@ -109,6 +109,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], "Timeout": 30, }, @@ -159,6 +163,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::IAM::Role", @@ -234,6 +242,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::ApiGateway::RestApi", @@ -418,11 +430,15 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::IAM::Role", }, - "lambdaapi2Deployment4ECB93738ba48d7cb88b4c2b9ec5c442ee1c99e9": Object { + "lambdaapi2Deployment4ECB937324608a148e4c74ee74e20f580623b2d9": Object { "DependsOn": Array [ "lambdaapi2proxyANY3F8E1D36", "lambdaapi2proxyE68FDFBC", @@ -439,7 +455,7 @@ Object { "lambdaapi2DeploymentStageprodCC9E3016": Object { "Properties": Object { "DeploymentId": Object { - "Ref": "lambdaapi2Deployment4ECB93738ba48d7cb88b4c2b9ec5c442ee1c99e9", + "Ref": "lambdaapi2Deployment4ECB937324608a148e4c74ee74e20f580623b2d9", }, "RestApiId": Object { "Ref": "lambdaapi239350ECC", @@ -462,6 +478,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::ApiGateway::Stage", @@ -755,6 +775,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::ApiGateway::RestApi", @@ -804,11 +828,15 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::IAM::Role", }, - "lambdaapiDeployment8E95B5854e05b687211f19a449136200fabf5846": Object { + "lambdaapiDeployment8E95B585b22be554088fbcc2c63fc037a54e995d": Object { "DependsOn": Array [ "lambdaapiproxyANYA94E968A", "lambdaapiproxyB573C729", @@ -825,7 +853,7 @@ Object { "lambdaapiDeploymentStageprod9598BC2F": Object { "Properties": Object { "DeploymentId": Object { - "Ref": "lambdaapiDeployment8E95B5854e05b687211f19a449136200fabf5846", + "Ref": "lambdaapiDeployment8E95B585b22be554088fbcc2c63fc037a54e995d", }, "RestApiId": Object { "Ref": "lambdaapiC1812993", @@ -848,6 +876,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::ApiGateway::Stage", diff --git a/src/constructs/rds/instance.test.ts b/src/constructs/rds/instance.test.ts index f87ccdafab..2c571a3350 100644 --- a/src/constructs/rds/instance.test.ts +++ b/src/constructs/rds/instance.test.ts @@ -3,8 +3,9 @@ import { SynthUtils } from "@aws-cdk/assert/lib/synth-utils"; import { Vpc } from "@aws-cdk/aws-ec2"; import { DatabaseInstanceEngine, ParameterGroup, PostgresEngineVersion } from "@aws-cdk/aws-rds"; import { Stack } from "@aws-cdk/core"; -import { simpleGuStackForTesting } from "../../../test/utils/simple-gu-stack"; -import type { SynthedStack } from "../../../test/utils/synthed-stack"; +import { simpleGuStackForTesting } from "../../../test/utils"; +import type { SynthedStack } from "../../../test/utils"; +import { TrackingTag } from "../../constants/library-info"; import { GuDatabaseInstance } from "./instance"; describe("The GuDatabaseInstance class", () => { @@ -100,6 +101,7 @@ describe("The GuDatabaseInstance class", () => { Ref: "Stage", }, }, + TrackingTag, ], }); }); diff --git a/src/patterns/__snapshots__/scheduled-lambda.test.ts.snap b/src/patterns/__snapshots__/scheduled-lambda.test.ts.snap index 0c8029d525..0011815367 100644 --- a/src/patterns/__snapshots__/scheduled-lambda.test.ts.snap +++ b/src/patterns/__snapshots__/scheduled-lambda.test.ts.snap @@ -56,6 +56,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], "Timeout": 30, }, @@ -156,6 +160,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::IAM::Role", diff --git a/src/patterns/__snapshots__/sns-lambda.test.ts.snap b/src/patterns/__snapshots__/sns-lambda.test.ts.snap index 7345fe97ab..340dc1b0a0 100644 --- a/src/patterns/__snapshots__/sns-lambda.test.ts.snap +++ b/src/patterns/__snapshots__/sns-lambda.test.ts.snap @@ -48,6 +48,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::SNS::Topic", @@ -89,6 +93,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], "Timeout": 30, }, @@ -205,6 +213,10 @@ Object { "Ref": "Stage", }, }, + Object { + "Key": "X-Gu-CDK-Version", + "Value": "0.31.0", + }, ], }, "Type": "AWS::IAM::Role", diff --git a/tsconfig.json b/tsconfig.json index cffaa79a30..c79d1cb45e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,8 @@ "inlineSources": true, "experimentalDecorators": true, "typeRoots": ["./node_modules/@types"], - "outDir": "lib" + "outDir": "lib", + "resolveJsonModule": true }, "include": ["src/**/*"], "exclude": ["node_modules", "test", "src/**/*.test.ts", "src/**/__snapshots__/**"]