From 75af51f851a4105176450dbf0ab79ba046c4fd4e Mon Sep 17 00:00:00 2001 From: Ethan Hitchcock <49368798+EHitchc@users.noreply.github.com> Date: Wed, 29 Apr 2026 16:02:49 +1200 Subject: [PATCH 1/2] feat: create pipe for cloudformation github deploy action tags input --- src/pipeline.ts | 8 ++++++++ test/github.test.ts | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/pipeline.ts b/src/pipeline.ts index d7daa7ed..9e432500 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -659,6 +659,14 @@ export class GitHubWorkflow extends PipelineBase { } const assumeRoleArn = stack.assumeRoleArn ? resolve(stack.assumeRoleArn) : undefined; + if (stack.tags && Object.keys(stack.tags).length > 0) { + const tags: Array<{ Key: string; Value: string }> = []; + for (const [key, value] of Object.entries(stack.tags)) { + tags.push({ Key: key, Value: value }); + } + params.tags = JSON.stringify(tags); + } + return { id: node.uniqueId, definition: { diff --git a/test/github.test.ts b/test/github.test.ts index 4222bd87..f4d90462 100644 --- a/test/github.test.ts +++ b/test/github.test.ts @@ -1,6 +1,6 @@ import { readFileSync } from 'fs'; import { join } from 'path'; -import { Stack, Stage } from 'aws-cdk-lib'; +import { Stack, Stage, Tags } from 'aws-cdk-lib'; import * as lambda from 'aws-cdk-lib/aws-lambda'; import { ShellStep } from 'aws-cdk-lib/pipelines'; import { GitHubExampleApp } from './example-app'; @@ -698,4 +698,35 @@ test('pipeline with cdkAssetVersion override', () => { expect(readFileSync(github.workflowPath, 'utf-8')).toMatchSnapshot(); }); +}); + +test('pipeline with tags applied to stack', () => { + withTemporaryDirectory((dir) => { + const github = new GitHubWorkflow(app, 'Pipeline', { + workflowPath: `${dir}/.github/workflows/deploy.yml`, + synth: new ShellStep('Build', { + installCommands: ['yarn'], + commands: ['yarn build'], + }), + }); + + const stage = new Stage(app, 'MyStack', { + env: { account: '111111111111', region: 'us-east-1' }, + }); + + const stack = new Stack(stage, 'MyStack'); + Tags.of(stack).add('Environment', 'Production'); + Tags.of(stack).add('Project', 'MyProject'); + + github.addStage(stage); + + app.synth(); + + const file = readFileSync(github.workflowPath, 'utf-8'); + expect(file).toContain('tags:'); + expect(file).toContain('"Key":"Environment"'); + expect(file).toContain('"Value":"Production"'); + expect(file).toContain('"Key":"Project"'); + expect(file).toContain('"Value":"MyProject"'); + }); }); \ No newline at end of file From e45b070efa44e0d5fb1f3e4c3eecc845e6e89845 Mon Sep 17 00:00:00 2001 From: Ethan Hitchcock <49368798+EHitchc@users.noreply.github.com> Date: Wed, 29 Apr 2026 16:04:10 +1200 Subject: [PATCH 2/2] chore: linting --- test/github.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/github.test.ts b/test/github.test.ts index f4d90462..8f48540f 100644 --- a/test/github.test.ts +++ b/test/github.test.ts @@ -729,4 +729,4 @@ test('pipeline with tags applied to stack', () => { expect(file).toContain('"Key":"Project"'); expect(file).toContain('"Value":"MyProject"'); }); -}); \ No newline at end of file +});