Tags

class aws_cdk.Tags(*args: Any, **kwargs)

Bases: object

Manages AWS tags for all resources within a construct scope.

ExampleMetadata:

infused

Example:

# mesh: appmesh.Mesh
# service: cloudmap.Service


node = appmesh.VirtualNode(self, "node",
    mesh=mesh,
    service_discovery=appmesh.ServiceDiscovery.cloud_map(service),
    listeners=[appmesh.VirtualNodeListener.http(
        port=8080,
        health_check=appmesh.HealthCheck.http(
            healthy_threshold=3,
            interval=Duration.seconds(5),
            path="/ping",
            timeout=Duration.seconds(2),
            unhealthy_threshold=2
        ),
        timeout=appmesh.HttpTimeout(
            idle=Duration.seconds(5)
        )
    )],
    backend_defaults=appmesh.BackendDefaults(
        tls_client_policy=appmesh.TlsClientPolicy(
            validation=appmesh.TlsValidation(
                trust=appmesh.TlsValidationTrust.file("/keys/local_cert_chain.pem")
            )
        )
    ),
    access_log=appmesh.AccessLog.from_file_path("/dev/stdout")
)

cdk.Tags.of(node).add("Environment", "Dev")

Methods

add(key, value, *, apply_to_launched_instances=None, exclude_resource_types=None, include_resource_types=None, priority=None)

add tags to the node of a construct and all its the taggable children.

Parameters:
  • key (str) –

  • value (str) –

  • apply_to_launched_instances (Optional[bool]) – Whether the tag should be applied to instances in an AutoScalingGroup. Default: true

  • exclude_resource_types (Optional[Sequence[str]]) – An array of Resource Types that will not receive this tag. An empty array will allow this tag to be applied to all resources. A non-empty array will apply this tag only if the Resource type is not in this array. Default: []

  • include_resource_types (Optional[Sequence[str]]) – An array of Resource Types that will receive this tag. An empty array will match any Resource. A non-empty array will apply this tag only to Resource types that are included in this array. Default: []

  • priority (Union[int, float, None]) – Priority of the tag operation. Higher or equal priority tags will take precedence. Setting priority will enable the user to control tags when they need to not follow the default precedence pattern of last applied and closest to the construct in the tree. Default: Default priorities: - 100 for SetTag - 200 for RemoveTag - 50 for tags added directly to CloudFormation resources

Return type:

None

remove(key, *, apply_to_launched_instances=None, exclude_resource_types=None, include_resource_types=None, priority=None)

remove tags to the node of a construct and all its the taggable children.

Parameters:
  • key (str) –

  • apply_to_launched_instances (Optional[bool]) – Whether the tag should be applied to instances in an AutoScalingGroup. Default: true

  • exclude_resource_types (Optional[Sequence[str]]) – An array of Resource Types that will not receive this tag. An empty array will allow this tag to be applied to all resources. A non-empty array will apply this tag only if the Resource type is not in this array. Default: []

  • include_resource_types (Optional[Sequence[str]]) – An array of Resource Types that will receive this tag. An empty array will match any Resource. A non-empty array will apply this tag only to Resource types that are included in this array. Default: []

  • priority (Union[int, float, None]) – Priority of the tag operation. Higher or equal priority tags will take precedence. Setting priority will enable the user to control tags when they need to not follow the default precedence pattern of last applied and closest to the construct in the tree. Default: Default priorities: - 100 for SetTag - 200 for RemoveTag - 50 for tags added directly to CloudFormation resources

Return type:

None

Static Methods

classmethod of(scope)

Returns the tags API for this scope.

Parameters:

scope (IConstruct) – The scope.

Return type:

Tags