# Tag

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

Implements: [IAspect](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IAspect.html)

- Source: [`core/lib/tag-aspect.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/core/lib/tag-aspect.ts#L96)
- Type last changed: v2.81.0 · 25 May 2023

## Example

TypeScript:

```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:

```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:

```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();
```

C# / .NET:

```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
});
```

Golang:

```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

TypeScript:

```ts
new Tag(key: string, value: string, props?: TagProps)
```

Python:

```python
Tag(key: str, value: str, props: typing.Optional[TagProps] = None)
```

Java:

```java
new Tag(String key, String value, TagProps props)
```

C# / .NET:

```csharp
new Tag(string key, string value, TagProps? props = null)
```

Golang:

```go
NewTag(Key *string, Value *string, Props TagProps)
```

## Properties

- `key`: string — The string key for the tag.

- `value`: string — The string value of the tag.

## Methods

- `visit(construct: IConstruct): void` — All aspects can visit an IConstruct.
