Skip to content

Commit

Permalink
Merge pull request #513 from guardian/aa/build-tags
Browse files Browse the repository at this point in the history
feat: Add build info as stack metadata and ASG tags
  • Loading branch information
akash1810 authored Aug 22, 2024
2 parents 264e42d + 88e1d1f commit 79d9dfd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
5 changes: 4 additions & 1 deletion cdk/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
jest.mock("@guardian/cdk/lib/constants/tracking-tag");
jest.mock('@guardian/cdk/lib/constants/tracking-tag');

process.env.GITHUB_RUN_NUMBER = 'TEST';
process.env.GITHUB_SHA = 'TEST';
12 changes: 12 additions & 0 deletions cdk/lib/__snapshots__/cdk-playground.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
exports[`The Deploy stack matches the snapshot 1`] = `
Object {
"Metadata": Object {
"gu:build:number": "TEST",
"gu:build:sha": "TEST",
"gu:cdk:constructs": Array [
"GuVpcParameter",
"GuSubnetListParameter",
Expand Down Expand Up @@ -145,6 +147,16 @@ Object {
"PropagateAtLaunch": true,
"Value": "cdk-playground",
},
Object {
"Key": "gu:build:number",
"PropagateAtLaunch": true,
"Value": "TEST",
},
Object {
"Key": "gu:build:sha",
"PropagateAtLaunch": true,
"Value": "TEST",
},
Object {
"Key": "gu:cdk:version",
"PropagateAtLaunch": true,
Expand Down
13 changes: 11 additions & 2 deletions cdk/lib/cdk-playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GuStack, GuStringParameter } from '@guardian/cdk/lib/constructs/core';
import { GuCname } from '@guardian/cdk/lib/constructs/dns';
import { GuFastlyLogsIamRole } from '@guardian/cdk/lib/constructs/iam';
import type { App } from 'aws-cdk-lib';
import { Duration } from 'aws-cdk-lib';
import { Duration, Tags } from 'aws-cdk-lib';
import { InstanceClass, InstanceSize, InstanceType } from 'aws-cdk-lib/aws-ec2';
import { Runtime } from 'aws-cdk-lib/aws-lambda';

Expand All @@ -26,7 +26,7 @@ export class CdkPlayground extends GuStack {
const ec2App = 'cdk-playground';
const ec2AppDomainName = 'cdk-playground.gutools.co.uk';

const { loadBalancer } = new GuPlayApp(this, {
const { loadBalancer, autoScalingGroup } = new GuPlayApp(this, {
app: ec2App,
instanceType: InstanceType.of(InstanceClass.T4G, InstanceSize.MICRO),
access: { scope: AccessScope.PUBLIC },
Expand Down Expand Up @@ -109,5 +109,14 @@ export class CdkPlayground extends GuStack {
domainName: lambdaDomainName,
resourceRecord: domain.domainNameAliasDomainName,
});

const { GITHUB_RUN_NUMBER = 'unknown', GITHUB_SHA = 'unknown' } =
process.env;

this.addMetadata('gu:build:number', GITHUB_RUN_NUMBER);
this.addMetadata('gu:build:sha', GITHUB_SHA);

Tags.of(autoScalingGroup).add('gu:build:number', GITHUB_RUN_NUMBER);
Tags.of(autoScalingGroup).add('gu:build:sha', GITHUB_SHA);
}
}

0 comments on commit 79d9dfd

Please sign in to comment.