Show / Hide Table of Contents

Class TagManager

TagManager facilitates a common implementation of tagging for Constructs.

Inheritance
System.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
// Example automatically generated from non-compiling source. May contain errors.
using Amazon.CDK;


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

    public MyConstruct(cdk.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(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

TagManager(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

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.

RemoveTag(String, Double)

Removes the specified tag from the array if it exists.

RenderTags()

Renders tags into the proper format based on TagType.

SetTag(String, String, Nullable<Double>, Nullable<Boolean>)

Adds the specified tag to the array of tags.

TagValues()

Render the tags in a readable format.

Constructors

TagManager(TagType, String, Object, ITagManagerOptions)

public TagManager(TagType tagType, string resourceTypeName, object tagStructure = null, ITagManagerOptions options = null)
Parameters
tagType TagType
resourceTypeName System.String
tagStructure System.Object
options ITagManagerOptions

TagManager(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

protected TagManager(ByRefValue reference)
Parameters
reference Amazon.JSII.Runtime.Deputy.ByRefValue

The Javascript-owned object reference

TagManager(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

protected TagManager(DeputyBase.DeputyProps props)
Parameters
props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps

The deputy props

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

System.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 System.String[]
exclude System.String[]
Returns

System.Boolean

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

System.Boolean

IsTaggable(Object)

Check whether the given construct is Taggable.

public static bool IsTaggable(object construct)
Parameters
construct System.Object
Returns

System.Boolean

RemoveTag(String, Double)

Removes the specified tag from the array if it exists.

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

The tag to remove.

priority System.Double

The priority of the remove operation.

RenderTags()

Renders tags into the proper format based on TagType.

public virtual object RenderTags()
Returns

System.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, Nullable<Double>, Nullable<Boolean>)

Adds the specified tag to the array of tags.

public virtual void SetTag(string key, string value, Nullable<double> priority = null, Nullable<bool> applyToLaunchedInstances = null)
Parameters
key System.String
value System.String
priority System.Nullable<System.Double>
applyToLaunchedInstances System.Nullable<System.Boolean>

TagValues()

Render the tags in a readable format.

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

System.Collections.Generic.IDictionary<System.String, System.String>

Back to top Generated by DocFX