Skip to content

feat: enable stack tagging#1462

Open
EHitchc wants to merge 2 commits intocdklabs:mainfrom
EHitchc:feat/enable-stack-tagging
Open

feat: enable stack tagging#1462
EHitchc wants to merge 2 commits intocdklabs:mainfrom
EHitchc:feat/enable-stack-tagging

Conversation

@EHitchc
Copy link
Copy Markdown
Contributor

@EHitchc EHitchc commented Apr 29, 2026

Fixes #730

The StackDeployment type accessed on the jobForDeploy method already has a tags property with the desired Key/Value pairs. This added code snippet converts the record of Key/Value pairs into the JSON-formatted string required by the inputs for the underlying aws-cloudformation-github-deploy action (https://github.com/aws-actions/aws-cloudformation-github-deploy/blob/1802e08d2ea549569d23bf4a7d704b5242cfc878/action.yml#L49-L51) before generating the final yaml file.

Sample workflow generated by added test (note addition of tags to deploy step):

      name: deploy
      on:
        push:
          branches:
            - main
        workflow_dispatch: {}
      jobs:
        Build-Build:
          name: Synthesize
          permissions:
            contents: read
            id-token: none
          runs-on: ubuntu-latest
          needs: []
          env: {}
          steps:
            - name: Checkout
              uses: actions/checkout@v6
            - name: Install
              run: yarn
            - name: Build
              run: yarn build
            - name: Upload cdk.out
              uses: actions/upload-artifact@v7
              with:
                name: cdk.out
                path: cdk.out
                include-hidden-files: true
        Assets-FileAsset1:
          name: Publish Assets Assets-FileAsset1
          needs:
            - Build-Build
          permissions:
            contents: read
            id-token: none
          runs-on: ubuntu-latest
          outputs:
            asset-hash: ${{ steps.Publish.outputs.asset-hash }}
          steps:
            - name: Download cdk.out
              uses: actions/download-artifact@v8
              with:
                name: cdk.out
                path: github.out
            - name: Install
              run: npm install --no-save cdk-assets
            - name: Authenticate Via GitHub Secrets
              uses: aws-actions/configure-aws-credentials@v6
              with:
                aws-region: us-west-2
                role-duration-seconds: 1800
                role-skip-session-tagging: true
                aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
                aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
            - id: Publish
              name: Publish Assets-FileAsset1
              run: /bin/bash ./cdk.out/assembly-MyStack/publish-Assets-FileAsset1-step.sh
        MyStack-MyStack-Deploy:
          name: Deploy MyStack098574E7
          permissions:
            contents: read
            id-token: none
          needs:
            - Build-Build
            - Assets-FileAsset1
          runs-on: ubuntu-latest
          steps:
            - name: Authenticate Via GitHub Secrets
              uses: aws-actions/configure-aws-credentials@v6
              with:
                aws-region: us-east-1
                role-duration-seconds: 1800
                role-skip-session-tagging: true
                aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
                aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
                role-to-assume: arn:aws:iam::111111111111:role/cdk-hnb659fds-deploy-role-111111111111-us-east-1
                role-external-id: Pipeline
            - id: Deploy
              uses: aws-actions/aws-cloudformation-github-deploy@v2
              with:
                name: MyStack-MyStack
                template: https://cdk-hnb659fds-assets-111111111111-us-east-1.s3.us-east-1.amazonaws.com/${{
                  needs.Assets-FileAsset1.outputs.asset-hash }}.json
                fail-on-empty-changeset: false
                role-arn: arn:aws:iam::111111111111:role/cdk-hnb659fds-cfn-exec-role-111111111111-us-east-1
                tags: '[{"Key":"Environment","Value":"Production"},{"Key":"Project","Value":"MyProject"}]'

auto-merge was automatically disabled April 29, 2026 21:48

Head branch was pushed to by a user without write access

@EHitchc EHitchc force-pushed the feat/enable-stack-tagging branch from 23f71ea to 25c754b Compare April 29, 2026 21:48
@EHitchc EHitchc force-pushed the feat/enable-stack-tagging branch from 25c754b to 32c2b36 Compare May 4, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot tag Cloudformation stack

1 participant