Tags Class
Manages AWS tags for all resources within a construct scope.
Example
declare const mesh: appmesh.Mesh;
declare const service: cloudmap.Service;
const node = new appmesh.VirtualNode(this, 'node', {
mesh,
serviceDiscovery: appmesh.ServiceDiscovery.cloudMap(service),
listeners: [appmesh.VirtualNodeListener.http({
port: 8080,
healthCheck: appmesh.HealthCheck.http({
healthyThreshold: 3,
interval: Duration.seconds(5),
path: '/ping',
timeout: Duration.seconds(2),
unhealthyThreshold: 2,
}),
timeout: {
idle: Duration.seconds(5),
},
})],
backendDefaults: {
tlsClientPolicy: {
validation: {
trust: appmesh.TlsValidationTrust.file('/keys/local_cert_chain.pem'),
},
},
},
accessLog: appmesh.AccessLog.fromFilePath('/dev/stdout'),
});
cdk.Tags.of(node).add('Environment', 'Dev');
Methods
add(key: string, value: string, props?: TagProps): voiddef add(self, key: str, value: str, props: typing.Optional[TagProps] = None) -> Nonepublic void add(String key, String value, TagProps props)public void Add(string key, string value, TagProps? props = null)func Add(Key *string, Value *string, Props TagProps)#notes
Tagging and CloudFormation Stacks
If the feature flag @aws-cdk/core:explicitStackTags is set to true (recommended modern behavior), Stacks will not automatically be tagged. Stack tags should be configured on Stacks directly (preferred), or you must explicitly include the resource type aws:cdk:stack in the includeResourceTypes array.
If the feature flag is set to false (legacy behavior) then both Stacks and resources in the indicated scope will both be tagged by default, which leads to tags being applied twice (once in the template, and then once again automatically by CloudFormation as part of the stack deployment). That behavior leads to loss of control as excludeResourceTypes will prevent tags from appearing in the template, but they will still be applied to the Stack and hence CloudFormation will still apply them to the resource.
of(scope: IConstruct): Tags // chainable@staticmethod def of(scope: IConstruct) -> Tagspublic static Tags of(IConstruct scope)public static Tags Of(IConstruct scope)func Of(Scope IConstruct) Tagsstatic#1 parameter
Parameters
scopescopescopescopeScope— The scope.
remove(key: string, props?: TagProps): voiddef remove(self, key: str, props: typing.Optional[TagProps] = None) -> Nonepublic void remove(String key, TagProps props)public void Remove(string key, TagProps? props = null)func Remove(Key *string, Props TagProps)#