Show / Hide Table of Contents

Class TagManager

TagManager facilitates a common implementation of tagging for Constructs.

Inheritance
object
TagManager
Namespace: Amazon.CDK
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class TagManager : DeputyBase
Syntax (vb)
Public Class TagManager Inherits DeputyBase
Remarks

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.

Examples
class MyConstruct : Resource, ITaggable
            {
                public readonly void Tags = new TagManager(TagType.KEY_VALUE, "Whatever::The::Type");

                public MyConstruct(Construct scope, string id) : base(scope, id)
                {

                    new CfnResource(this, "Resource", new CfnResourceProps {
                        Type = "Whatever::The::Type",
                        Properties = new Dictionary<string, object> {
                            // ...
                            { "Tags", Tags.RenderedTags }
                        }
                    });
                }
            }

Synopsis

Constructors

TagManager(TagType, string, object?, ITagManagerOptions?)

TagManager facilitates a common implementation of tagging for Constructs.

Properties

RenderedTags

A lazy value that represents the rendered tags at synthesis time.

TagPropertyName

The property name for tag values.

Methods

ApplyTagAspectHere(string[]?, string[]?)

Determine if the aspect applies here.

HasTags()

Returns true if there are any tags defined.

IsTaggable(object)

Check whether the given construct is Taggable.

IsTaggableV2(object)

Check whether the given construct is ITaggableV2.

Of(object)

Return the TagManager associated with the given construct, if any.

RemoveTag(string, double)

Removes the specified tag from the array if it exists.

RenderTags(object?)

Renders tags into the proper format based on TagType.

SetTag(string, string, double?, bool?)

Adds the specified tag to the array of tags.

TagValues()

Render the tags in a readable format.

Constructors

TagManager(TagType, string, object?, ITagManagerOptions?)

TagManager facilitates a common implementation of tagging for Constructs.

public TagManager(TagType tagType, string resourceTypeName, object? initialTags = null, ITagManagerOptions? options = null)
Parameters
tagType TagType
resourceTypeName string
initialTags object
options ITagManagerOptions
Remarks

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.

Examples
class MyConstruct : Resource, ITaggable
            {
                public readonly void Tags = new TagManager(TagType.KEY_VALUE, "Whatever::The::Type");

                public MyConstruct(Construct scope, string id) : base(scope, id)
                {

                    new CfnResource(this, "Resource", new CfnResourceProps {
                        Type = "Whatever::The::Type",
                        Properties = new Dictionary<string, object> {
                            // ...
                            { "Tags", Tags.RenderedTags }
                        }
                    });
                }
            }

Properties

RenderedTags

A lazy value that represents the rendered tags at synthesis time.

public virtual IResolvable RenderedTags { get; }
Property Value

IResolvable

Remarks

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.

TagPropertyName

The property name for tag values.

public virtual string TagPropertyName { get; }
Property Value

string

Remarks

Normally this is tags but some resources choose a different name. Cognito UserPool uses UserPoolTags

Methods

ApplyTagAspectHere(string[]?, string[]?)

Determine if the aspect applies here.

public virtual bool ApplyTagAspectHere(string[]? include = null, string[]? exclude = null)
Parameters
include string[]
exclude string[]
Returns

bool

Remarks

Looks at the include and exclude resourceTypeName arrays to determine if the aspect applies here

HasTags()

Returns true if there are any tags defined.

public virtual bool HasTags()
Returns

bool

Remarks

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.

IsTaggable(object)

Check whether the given construct is Taggable.

public static bool IsTaggable(object construct)
Parameters
construct object
Returns

bool

Remarks

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.

IsTaggableV2(object)

Check whether the given construct is ITaggableV2.

public static bool IsTaggableV2(object construct)
Parameters
construct object
Returns

bool

Remarks

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.

Of(object)

Return the TagManager associated with the given construct, if any.

public static TagManager? Of(object construct)
Parameters
construct object
Returns

TagManager

Remarks

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.

RemoveTag(string, double)

Removes the specified tag from the array if it exists.

public virtual void RemoveTag(string key, double priority)
Parameters
key string

The tag to remove.

priority double

The priority of the remove operation.

Remarks

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.

RenderTags(object?)

Renders tags into the proper format based on TagType.

public virtual object RenderTags(object? combineWithTags = null)
Parameters
combineWithTags object
Returns

object

Remarks

This method will eagerly render the tags currently applied. In most cases, you should be using tagManager.renderedTags instead, which will return a Lazy value that will resolve to the correct tags at synthesis time.

SetTag(string, string, double?, bool?)

Adds the specified tag to the array of tags.

public virtual void SetTag(string key, string value, double? priority = null, bool? applyToLaunchedInstances = null)
Parameters
key string
value string
priority double?
applyToLaunchedInstances bool?
Remarks

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.

TagValues()

Render the tags in a readable format.

public virtual IDictionary<string, string> TagValues()
Returns

IDictionary<string, string>

Remarks

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.

Back to top Generated by DocFX