Class CfnTagAssociation

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.98.0 (build 00b106d)", date="2024-05-08T21:35:09.101Z") @Stability(Stable) public class CfnTagAssociation extends CfnResource implements IInspectable
The AWS::LakeFormation::TagAssociation resource represents an assignment of an LF-tag to a Data Catalog resource (database, table, or column).

During a stack operation, CloudFormation calls AWS Lake Formation AddLFTagsToResource API to create a TagAssociation resource and calls the RemoveLFTagsToResource API 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

    • CfnTagAssociation

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

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

      @Stability(Stable) public CfnTagAssociation(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CfnTagAssociationProps 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.
    • getAttrResourceIdentifier

      @Stability(Stable) @NotNull public String getAttrResourceIdentifier()
      Json encoding of the input resource.

      Examples - Database: {"Catalog":null,"Database":{"CatalogId":"123456789012","Name":"ExampleDbName"},"Table":null,"TableWithColumns":null}

      • Table: {"Catalog":null,"Database":null,"Table":{"CatalogId":"123456789012","DatabaseName":"ExampleDbName","Name":"ExampleTableName","TableWildcard":null},"TableWithColumns":null}
      • Columns: {"Catalog":null,"Database":null,"Table":null,"TableWithColumns":{"CatalogId":"123456789012","DatabaseName":"ExampleDbName","Name":"ExampleTableName","ColumnNames":["ExampleColName1","ExampleColName2"]}}
    • getAttrTagsIdentifier

      @Stability(Stable) @NotNull public String getAttrTagsIdentifier()
      Json encoding of the input LFTags list.

      For example: [{"CatalogId":null,"TagKey":"tagKey1","TagValues":null},{"CatalogId":null,"TagKey":"tagKey2","TagValues":null}]

    • getCfnProperties

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

      @Stability(Stable) @NotNull public Object getLfTags()
      A structure containing an LF-tag key-value pair.
    • setLfTags

      @Stability(Stable) public void setLfTags(@NotNull IResolvable value)
      A structure containing an LF-tag key-value pair.
    • setLfTags

      @Stability(Stable) public void setLfTags(@NotNull List<Object> value)
      A structure containing an LF-tag key-value pair.
    • getResource

      @Stability(Stable) @NotNull public Object getResource()
      UTF-8 string (valid values: DATABASE | TABLE ).
    • setResource

      @Stability(Stable) public void setResource(@NotNull IResolvable value)
      UTF-8 string (valid values: DATABASE | TABLE ).
    • setResource

      @Stability(Stable) public void setResource(@NotNull CfnTagAssociation.ResourceProperty value)
      UTF-8 string (valid values: DATABASE | TABLE ).