Class TagManager

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.core.TagManager
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:29:55.151Z") @Stability(Stable) public class TagManager extends software.amazon.jsii.JsiiObject
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:

 import software.amazon.awscdk.core.*;
 public class MyConstruct extends Resource implements ITaggable {
     public final Object tags;
     public MyConstruct(Construct scope, String id) {
         super(scope, id);
         CfnResource.Builder.create(this, "Resource")
                 .type("Whatever::The::Type")
                 .properties(Map.of(
                         // ...
                         "Tags", this.tags.getRenderedTags()))
                 .build();
     }
 }
 
  • Constructor Details

    • TagManager

      protected TagManager(software.amazon.jsii.JsiiObjectRef objRef)
    • TagManager

      protected TagManager(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • TagManager

      @Stability(Stable) public TagManager(@NotNull TagType tagType, @NotNull String resourceTypeName, @Nullable Object tagStructure, @Nullable TagManagerOptions options)
      Parameters:
      tagType - This parameter is required.
      resourceTypeName - This parameter is required.
      tagStructure -
      options -
    • TagManager

      @Stability(Stable) public TagManager(@NotNull TagType tagType, @NotNull String resourceTypeName, @Nullable Object tagStructure)
      Parameters:
      tagType - This parameter is required.
      resourceTypeName - This parameter is required.
      tagStructure -
    • TagManager

      @Stability(Stable) public TagManager(@NotNull TagType tagType, @NotNull String resourceTypeName)
      Parameters:
      tagType - This parameter is required.
      resourceTypeName - This parameter is required.
  • Method Details

    • isTaggable

      @Stability(Stable) @NotNull public static Boolean isTaggable(@NotNull Object construct)
      Check whether the given construct is Taggable.

      Parameters:
      construct - This parameter is required.
    • applyTagAspectHere

      @Stability(Stable) @NotNull public Boolean applyTagAspectHere(@Nullable List<String> include, @Nullable List<String> exclude)
      Determine if the aspect applies here.

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

      Parameters:
      include -
      exclude -
    • applyTagAspectHere

      @Stability(Stable) @NotNull public Boolean applyTagAspectHere(@Nullable List<String> include)
      Determine if the aspect applies here.

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

      Parameters:
      include -
    • applyTagAspectHere

      @Stability(Stable) @NotNull public Boolean applyTagAspectHere()
      Determine if the aspect applies here.

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

    • hasTags

      @Stability(Stable) @NotNull public Boolean hasTags()
      Returns true if there are any tags defined.
    • removeTag

      @Stability(Stable) public void removeTag(@NotNull String key, @NotNull Number priority)
      Removes the specified tag from the array if it exists.

      Parameters:
      key - The tag to remove. This parameter is required.
      priority - The priority of the remove operation. This parameter is required.
    • renderTags

      @Stability(Stable) @NotNull public Object renderTags()
      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 a Lazy value that will resolve to the correct tags at synthesis time.

    • setTag

      @Stability(Stable) public void setTag(@NotNull String key, @NotNull String value, @Nullable Number priority, @Nullable Boolean applyToLaunchedInstances)
      Adds the specified tag to the array of tags.

      Parameters:
      key - This parameter is required.
      value - This parameter is required.
      priority -
      applyToLaunchedInstances -
    • setTag

      @Stability(Stable) public void setTag(@NotNull String key, @NotNull String value, @Nullable Number priority)
      Adds the specified tag to the array of tags.

      Parameters:
      key - This parameter is required.
      value - This parameter is required.
      priority -
    • setTag

      @Stability(Stable) public void setTag(@NotNull String key, @NotNull String value)
      Adds the specified tag to the array of tags.

      Parameters:
      key - This parameter is required.
      value - This parameter is required.
    • tagValues

      @Stability(Stable) @NotNull public Map<String,String> tagValues()
      Render the tags in a readable format.
    • getRenderedTags

      @Stability(Stable) @NotNull public IResolvable getRenderedTags()
      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.

    • getTagPropertyName

      @Stability(Stable) @NotNull public String getTagPropertyName()
      The property name for tag values.

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