Skip to content

Commit cec737c

Browse files
committed
feat: Add gu:riff-raff-project tag to resources
1 parent 1824bae commit cec737c

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

.changeset/thirty-schools-pay.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@guardian/cdk": minor
3+
---
4+
5+
Add optional `riffRaffProjectName` property to `GuStackProps` representing the name of the Riff-Raff project used to deploy these resources.
6+
If provided, it is used as the value of the `gu:riff-raff-project` tag on all resources.
7+
8+
See also https://github.com/guardian/riffraff-platform.

src/constructs/core/stack.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ export interface GuStackProps extends Omit<StackProps, "stackName"> {
2828
*/
2929
app?: string;
3030

31+
/**
32+
* The name of the Riff-Raff project used to deploy these resources.
33+
* If provided, it is used as the value of the `gu:riff-raff-project` tag on all resources.
34+
*
35+
* @see https://github.com/guardian/riffraff-platform
36+
*/
37+
riffRaffProjectName?: string;
38+
3139
/**
3240
* The AWS CloudFormation stack name (as shown in the AWS CloudFormation UI).
3341
* @defaultValue the `GU_CFN_STACK_NAME` environment variable
@@ -78,6 +86,7 @@ export class GuStack extends Stack implements StackStageIdentity {
7886
public readonly stack: string;
7987
public readonly stage: string;
8088
public readonly app: string | undefined;
89+
public readonly riffRaffProjectName: string | undefined;
8190

8291
/**
8392
* The repository name, if it can be determined from the context or the git remote origin url.
@@ -115,7 +124,14 @@ export class GuStack extends Stack implements StackStageIdentity {
115124

116125
// eslint-disable-next-line custom-rules/valid-constructors -- GuStack is the exception as it must take an App
117126
constructor(scope: App, id: string, props: GuStackProps) {
118-
const { cloudFormationStackName = process.env.GU_CFN_STACK_NAME, stack, stage, app, withoutTags } = props;
127+
const {
128+
cloudFormationStackName = process.env.GU_CFN_STACK_NAME,
129+
stack,
130+
stage,
131+
app,
132+
riffRaffProjectName,
133+
withoutTags,
134+
} = props;
119135

120136
super(scope, id, {
121137
...props,
@@ -129,6 +145,7 @@ export class GuStack extends Stack implements StackStageIdentity {
129145
this.stack = stack;
130146
this.stage = stage.toUpperCase();
131147
this.app = app;
148+
this.riffRaffProjectName = riffRaffProjectName;
132149
this.repositoryName = this.tryGetRepositoryTag();
133150

134151
if (!withoutTags) {
@@ -140,6 +157,10 @@ export class GuStack extends Stack implements StackStageIdentity {
140157
this.addTag("App", this.app);
141158
}
142159

160+
if (this.riffRaffProjectName) {
161+
this.addTag("gu:riff-raff-project", this.riffRaffProjectName);
162+
}
163+
143164
if (this.repositoryName) {
144165
this.addTag(MetadataKeys.REPOSITORY_NAME, this.repositoryName);
145166
}

0 commit comments

Comments
 (0)