java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
All Implemented Interfaces:
IInspectable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-12-06T14:43:21.122Z") @Stability(Stable) public class CfnTag extends CfnResource implements IInspectable
The AWS::LakeFormation::Tag resource represents an LF-tag, which consists of a key and one or more possible values for the key.

During a stack operation, AWS CloudFormation calls the AWS Lake Formation CreateLFTag API to create a tag, and UpdateLFTag API to update a tag resource, and a DeleteLFTag to delete it.

Example:

 import software.amazon.awscdk.*;
 import software.amazon.awscdk.services.glue.alpha.S3Table;
 import software.amazon.awscdk.services.glue.alpha.Database;
 import software.amazon.awscdk.services.glue.alpha.DataFormat;
 import software.amazon.awscdk.services.glue.alpha.Schema;
 import software.amazon.awscdk.services.lakeformation.CfnDataLakeSettings;
 import software.amazon.awscdk.services.lakeformation.CfnTag;
 import software.amazon.awscdk.services.lakeformation.CfnTagAssociation;
 Stack stack;
 String accountId;
 String tagKey = "aws";
 String[] tagValues = List.of("dev");
 Database database = new Database(this, "Database");
 S3Table table = S3Table.Builder.create(this, "Table")
         .database(database)
         .columns(List.of(Column.builder()
                 .name("col1")
                 .type(Schema.STRING)
                 .build(), Column.builder()
                 .name("col2")
                 .type(Schema.STRING)
                 .build()))
         .dataFormat(DataFormat.CSV)
         .build();
 DefaultStackSynthesizer synthesizer = (DefaultStackSynthesizer)stack.getSynthesizer();
 CfnDataLakeSettings.Builder.create(this, "DataLakeSettings")
         .admins(List.of(DataLakePrincipalProperty.builder()
                 .dataLakePrincipalIdentifier(stack.formatArn(ArnComponents.builder()
                         .service("iam")
                         .resource("role")
                         .region("")
                         .account(accountId)
                         .resourceName("Admin")
                         .build()))
                 .build(), DataLakePrincipalProperty.builder()
                 // The CDK cloudformation execution role.
                 .dataLakePrincipalIdentifier(synthesizer.cloudFormationExecutionRoleArn.replace("${AWS::Partition}", "aws"))
                 .build()))
         .build();
 CfnTag tag = CfnTag.Builder.create(this, "Tag")
         .catalogId(accountId)
         .tagKey(tagKey)
         .tagValues(tagValues)
         .build();
 LFTagPairProperty lfTagPairProperty = LFTagPairProperty.builder()
         .catalogId(accountId)
         .tagKey(tagKey)
         .tagValues(tagValues)
         .build();
 CfnTagAssociation tagAssociation = CfnTagAssociation.Builder.create(this, "TagAssociation")
         .lfTags(List.of(lfTagPairProperty))
         .resource(ResourceProperty.builder()
                 .tableWithColumns(TableWithColumnsResourceProperty.builder()
                         .databaseName(database.getDatabaseName())
                         .columnNames(List.of("col1", "col2"))
                         .catalogId(accountId)
                         .name(table.getTableName())
                         .build())
                 .build())
         .build();
 tagAssociation.node.addDependency(tag);
 tagAssociation.node.addDependency(table);
 

See Also:
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnTag

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

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

      @Stability(Stable) public CfnTag(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnTagProps props)
      Parameters:
      scope - Scope in which this resource is defined. This parameter is required.
      id - Construct identifier for this resource (unique in its scope). This parameter is required.
      props - Resource properties. This parameter is required.
  • Method Details

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      Parameters:
      inspector - tree inspector to collect and process attributes. This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getTagKey

      @Stability(Stable) @NotNull public String getTagKey()
      UTF-8 string, not less than 1 or more than 255 bytes long, matching the single-line string pattern .
    • setTagKey

      @Stability(Stable) public void setTagKey(@NotNull String value)
      UTF-8 string, not less than 1 or more than 255 bytes long, matching the single-line string pattern .
    • getTagValues

      @Stability(Stable) @NotNull public List<String> getTagValues()
      An array of UTF-8 strings, not less than 1 or more than 50 strings.
    • setTagValues

      @Stability(Stable) public void setTagValues(@NotNull List<String> value)
      An array of UTF-8 strings, not less than 1 or more than 50 strings.
    • getCatalogId

      @Stability(Stable) @Nullable public String getCatalogId()
      Catalog id string, not less than 1 or more than 255 bytes long, matching the single-line string pattern .
    • setCatalogId

      @Stability(Stable) public void setCatalogId(@Nullable String value)
      Catalog id string, not less than 1 or more than 255 bytes long, matching the single-line string pattern .