Skip to content
v2.275.0

Tag Class ​

The Tag Aspect will handle adding a tag to this node and cascading tags to children.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
const tag = new cdk.Tag('key', 'value', /* all optional props */ {
  applyToLaunchedInstances: false,
  excludeResourceTypes: ['excludeResourceTypes'],
  includeResourceTypes: ['includeResourceTypes'],
  priority: 123,
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk

tag = cdk.Tag("key", "value",
    apply_to_launched_instances=False,
    exclude_resource_types=["excludeResourceTypes"],
    include_resource_types=["includeResourceTypes"],
    priority=123
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.*;

Tag tag = Tag.Builder.create("key", "value")
        .applyToLaunchedInstances(false)
        .excludeResourceTypes(List.of("excludeResourceTypes"))
        .includeResourceTypes(List.of("includeResourceTypes"))
        .priority(123)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK;

var tag = new Tag("key", "value", new TagProps {
    ApplyToLaunchedInstances = false,
    ExcludeResourceTypes = new [] { "excludeResourceTypes" },
    IncludeResourceTypes = new [] { "includeResourceTypes" },
    Priority = 123
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import cdk "github.com/aws/aws-cdk-go/awscdk"

tag := cdk.NewTag(jsii.String("key"), jsii.String("value"), &TagProps{
	ApplyToLaunchedInstances: jsii.Boolean(false),
	ExcludeResourceTypes: []*string{
		jsii.String("excludeResourceTypes"),
	},
	IncludeResourceTypes: []*string{
		jsii.String("includeResourceTypes"),
	},
	Priority: jsii.Number(123),
})

Initializer ​

ts
new Tag(key: string, value: string, props?: TagProps)
python
Tag(key: str, value: str, props: typing.Optional[TagProps] = None)
java
new Tag(String key, String value, TagProps props)
csharp
new Tag(string key, string value, TagProps? props = null)
go
NewTag(Key *string, Value *string, Props TagProps)

Properties ​

keystringkeystrkeyStringKeystringKey*string#
The string key for the tag.
valuestringvaluestrvalueStringValuestringValue*string#
The string value of the tag.

Methods ​

visit(construct: IConstruct): voiddef visit(self, construct: IConstruct) -> Nonepublic void visit(IConstruct construct)public void Visit(IConstruct construct)func Visit(Construct IConstruct)#
All aspects can visit an IConstruct.