TagManager
- class aws_cdk.TagManager(tag_type, resource_type_name, initial_tags=None, *, tag_property_name=None)
Bases:
object
TagManager facilitates a common implementation of tagging for Constructs.
Normally, you do not need to use this class, as the CloudFormation specification will indicate which resources are taggable. However, sometimes you will need this to make custom resources taggable. Used
tagManager.renderedTags
to obtain a value that will resolve to the tags at synthesis time.Example:
@jsii.implements(ITaggable) class MyConstruct(Resource): def __init__(self, scope, id): super().__init__(scope, id) CfnResource(self, "Resource", type="Whatever::The::Type", properties={ # ... "Tags": self.tags.rendered_tags } )
- Parameters:
tag_type (
TagType
) –resource_type_name (
str
) –initial_tags (
Any
) –tag_property_name (
Optional
[str
]) – The name of the property in CloudFormation for these tags. Normally this istags
, but Cognito UserPool uses UserPoolTags Default: “tags”
Methods
- apply_tag_aspect_here(include=None, exclude=None)
Determine if the aspect applies here.
Looks at the include and exclude resourceTypeName arrays to determine if the aspect applies here
- Parameters:
include (
Optional
[Sequence
[str
]]) –exclude (
Optional
[Sequence
[str
]]) –
- Return type:
bool
- has_tags()
Returns true if there are any tags defined.
- Return type:
bool
- remove_tag(key, priority)
Removes the specified tag from the array if it exists.
- Parameters:
key (
str
) – The tag to remove.priority (
Union
[int
,float
]) – The priority of the remove operation.
- Return type:
None
- render_tags(combine_with_tags=None)
Renders tags into the proper format based on TagType.
This method will eagerly render the tags currently applied. In most cases, you should be using
tagManager.renderedTags
instead, which will return aLazy
value that will resolve to the correct tags at synthesis time.- Parameters:
combine_with_tags (
Any
) –- Return type:
Any
- set_tag(key, value, priority=None, apply_to_launched_instances=None)
Adds the specified tag to the array of tags.
- Parameters:
key (
str
) –value (
str
) –priority (
Union
[int
,float
,None
]) –apply_to_launched_instances (
Optional
[bool
]) –
- Return type:
None
- tag_values()
Render the tags in a readable format.
- Return type:
Mapping
[str
,str
]
Attributes
- rendered_tags
A lazy value that represents the rendered tags at synthesis time.
If you need to make a custom construct taggable, use the value of this property to pass to the
tags
property of the underlying construct.
- tag_property_name
The property name for tag values.
Normally this is
tags
but some resources choose a different name. Cognito UserPool uses UserPoolTags
Static Methods
- classmethod is_taggable(construct)
Check whether the given construct is Taggable.
- Parameters:
construct (
Any
) –- Return type:
bool
- classmethod is_taggable_v2(construct)
Check whether the given construct is ITaggableV2.
- Parameters:
construct (
Any
) –- Return type:
bool
- classmethod of(construct)
Return the TagManager associated with the given construct, if any.
- Parameters:
construct (
Any
) –- Return type:
Optional
[TagManager
]