Skip to content

Instantly share code, notes, and snippets.

@cmaster11
Created April 18, 2024 05:52
Show Gist options
  • Save cmaster11/a681f1206c9aca394e16d46d1e6069d0 to your computer and use it in GitHub Desktop.
Save cmaster11/a681f1206c9aca394e16d46d1e6069d0 to your computer and use it in GitHub Desktop.
Markdium-CDK: Force-tagging stacks with a repository name
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