Skip to content
v2.275.0

CfnTagAssociationProps Struct ​

Properties for defining a CfnTagAssociation.

Example ​

ts
import * as cdk from 'aws-cdk-lib';
import { S3Table, Database, DataFormat, Schema } from 'aws-cdk-lib/aws-glue';
import { CfnDataLakeSettings, CfnTag, CfnTagAssociation } from 'aws-cdk-lib/aws-lakeformation';

declare const stack: cdk.Stack;
declare const accountId: string;

const tagKey = 'aws';
const tagValues = ['dev'];

const database = new Database(this, 'Database');

const table = new S3Table(this, 'Table', {
  database,
  columns: [
    {
      name: 'col1',
      type: Schema.STRING,
    },
    {
      name: 'col2',
      type: Schema.STRING,
    }
  ],
  dataFormat: DataFormat.CSV,
});

const synthesizer = stack.synthesizer as cdk.DefaultStackSynthesizer;
new CfnDataLakeSettings(this, 'DataLakeSettings', {
  admins: [
    {
      dataLakePrincipalIdentifier: stack.formatArn({
        service: 'iam',
        resource: 'role',
        region: '',
        account: accountId,
        resourceName: 'Admin',
      }),
    },
    {
      // The CDK cloudformation execution role.
      dataLakePrincipalIdentifier: synthesizer.cloudFormationExecutionRoleArn.replace('${AWS::Partition}', 'aws'),
    },
  ],
});

const tag = new CfnTag(this, 'Tag', {
  catalogId: accountId,
  tagKey,
  tagValues,
});

const lfTagPairProperty: CfnTagAssociation.LFTagPairProperty = {
  catalogId: accountId,
  tagKey,
  tagValues,
};

const tagAssociation = new CfnTagAssociation(this, 'TagAssociation', {
  lfTags: [lfTagPairProperty],
  resource: {
    tableWithColumns: {
      databaseName: database.databaseName,
      columnNames: ['col1', 'col2'],
      catalogId: accountId,
      name: table.tableName,
    }
  }
});

tagAssociation.node.addDependency(tag);
tagAssociation.node.addDependency(table);

Properties ​

lfTagsIResolvable | IResolvable | CfnTagAssociation.LFTagPairProperty[]lf_tagstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, LFTagPairProperty]]]lfTagsIResolvableLfTagsIResolvableLfTagsinterface{}required#
A structure containing an LF-tag key-value pair.
resourceIResolvable | CfnTagAssociation.ResourcePropertyresourcetyping.Union[IResolvable, ResourceProperty]resourceIResolvableResourceIResolvableResourceinterface{}required#
UTF-8 string (valid values: `DATABASE | TABLE` ).

The resource for which the LF-tag policy applies.