How to add a tag to an AWS-CDK specific construct or even better one tag definition to all ressources created within the stack?
Using the Java
SDK:
public class CdkInitClusterApp {
public static void main(final String[] args) {
final App app = new App();
final CdkInitClusterStack cdkInitClusterStack = new CdkInitClusterStack(app, "CdkInitClusterStack");
Tag.add(cdkInitClusterStack, "Project", "Value");
app.synth();
}
}
Then recreate the jar
mvn clean compile package
And run the cdk diff
for verify the changes, the output will be similar to the following one:
(base) [alessiosavi@localhost cdk-init-cluster]$ cdk diff
CdkInitClusterStack
Resources
[~] AWS::DynamoDB::Table cdk-test-table cdktesttableB0274F47
└─ [+] Tags
└─ [{"Key":"Project","Value":"Value"}]