Skip to content

Commit

Permalink
feat: Add build info as stack metadata and ASG tags
Browse files Browse the repository at this point in the history
  • Loading branch information
akash1810 committed Aug 22, 2024
1 parent 264e42d commit 7047463
Show file tree
Hide file tree
Showing 2 changed files with 15 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';
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 7047463

Please sign in to comment.