Created
April 18, 2024 05:52
-
-
Save cmaster11/a681f1206c9aca394e16d46d1e6069d0 to your computer and use it in GitHub Desktop.
Markdium-CDK: Force-tagging stacks with a repository name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as cdk from 'aws-cdk-lib'; | |
export type KiwiSynthesizerProps = cdk.DefaultStackSynthesizerProps & { | |
forcedTags: Record; | |
}; | |
export class KiwiSynthesizer extends cdk.DefaultStackSynthesizer { | |
readonly forcedTags: KiwiSynthesizerProps['forcedTags']; | |
constructor(props: KiwiSynthesizerProps) { | |
super(props); | |
this.forcedTags = props.forcedTags; | |
} | |
bind(stack: cdk.Stack) { | |
super.bind(stack); | |
// Add every forced tag to the Stack | |
for (const tag in this.forcedTags) { | |
cdk.Tags.of(this.boundStack).add(tag, this.forcedTags[tag]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment