I have deployed 2 services using aws CDK typescript. One of the services by default got listed in Tags of AWS Cost Explorer service:
So I tried to add tag to another service :
export class CdkStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props: scStackProps<ICdkStackProps>) {
super(scope, id, props);
const {config, context} = props;
const vpc = ec2.Vpc.fromLookup(this, "vpc", {
vpcName: "baseInfrastructure/vpc",
});
cdk.Tags.of(this).add("aws:cloudformation:stack-name", `${config.container.name}`);
But got the error in the Cloudformation stack:
UPDATE_FAILED aws: prefixed tag key names are not allowed for external use.
So please let me know where I am wrong and how to fix this issue so that I can see my both services in AWS Cost Explorer tags.
CodePudding user response:
As the message says, you cannot create aws:
-prefixed tags, only AWS can manage those.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resource-tags.html
These tags are created automatically and propagated to all supported resources. Create your own custom tags if that is not sufficient.