When trying to add tags to a stack, I'm receiving the following error:
โ MyStack failed: InvalidParameterType: Expected params.Tags[0].Value to be a string
Here is how I'm adding tags:
const stack = new AccountSetupStack(app, 'AccountSetupStack', {
"description": "Account setup"
});
stack.tags.setTag("StackName", cdk.Aws.STACK_NAME, 0, true)
Adding tags directly to the stack also produces the same error:
const stack = new AccountSetupStack(app, 'AccountSetupStack', {
"description": "Account setup",
"tags": {
"StackName": cdk.Aws.STACK_NAME
}
});
stack.tags.setTag("StackName", cdk.Aws.STACK_NAME, 0, true)
This is :bug: Bug Report
CloudFormation stack tags are applied upon stack creation and not during deployment and therefore they cannot use pseudo parameters like Aws.STACK_NAME.
You can use stack.stackName instead, which is early-bound:
stack.tags.setTag('StackName', stack.stackName);
We should add a validation that will emit a more informative error.
Thanks for explanation. I'm truly learning a lot here.
I'd say @eladb answer resolves the issue. Thanks!!!