# CfnTagAssociationProps

Properties for defining a `CfnTagAssociation`.

Used as props by: [CfnTagAssociation](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lakeformation.CfnTagAssociation.html)

- Source: Generated at build time
- Type last changed: v2.31.0 · 6 Jul 2022

## Example

TypeScript:

```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);
```

Python:

```python
import aws_cdk as cdk
from aws_cdk.aws_glue import S3Table, Database, DataFormat, Schema
from aws_cdk.aws_lakeformation import CfnDataLakeSettings, CfnTag, CfnTagAssociation

# stack: cdk.Stack
# account_id: str

tag_key = "aws"
tag_values = ["dev"]

database = Database(self, "Database")

table = S3Table(self, "Table",
    database=database,
    columns=[cdk.aws_glue.Column(
        name="col1",
        type=Schema.STRING
    ), cdk.aws_glue.Column(
        name="col2",
        type=Schema.STRING
    )
    ],
    data_format=DataFormat.CSV
)

synthesizer = stack.synthesizer
CfnDataLakeSettings(self, "DataLakeSettings",
    admins=[CfnDataLakeSettings.DataLakePrincipalProperty(
        data_lake_principal_identifier=stack.format_arn(
            service="iam",
            resource="role",
            region="",
            account=account_id,
            resource_name="Admin"
        )
    ), CfnDataLakeSettings.DataLakePrincipalProperty(
        # The CDK cloudformation execution role.
        data_lake_principal_identifier=synthesizer.cloud_formation_execution_role_arn.replace("${AWS::Partition}", "aws")
    )
    ]
)

tag = CfnTag(self, "Tag",
    catalog_id=account_id,
    tag_key=tag_key,
    tag_values=tag_values
)

lf_tag_pair_property = CfnTagAssociation.LFTagPairProperty(
    catalog_id=account_id,
    tag_key=tag_key,
    tag_values=tag_values
)

tag_association = CfnTagAssociation(self, "TagAssociation",
    lf_tags=[lf_tag_pair_property],
    resource=CfnTagAssociation.ResourceProperty(
        table_with_columns=CfnTagAssociation.TableWithColumnsResourceProperty(
            database_name=database.database_name,
            column_names=["col1", "col2"],
            catalog_id=account_id,
            name=table.table_name
        )
    )
)

tag_association.node.add_dependency(tag)
tag_association.node.add_dependency(table)
```

Java:

```java
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.glue.S3Table;
import software.amazon.awscdk.services.glue.Database;
import software.amazon.awscdk.services.glue.DataFormat;
import software.amazon.awscdk.services.glue.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);
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK;
using Amazon.CDK.AWS.Glue;
using Amazon.CDK.AWS.LakeFormation;

Stack stack;
string accountId;

var tagKey = "aws";
var tagValues = new [] { "dev" };

var database = new Database(this, "Database");

var table = new S3Table(this, "Table", new S3TableProps {
    Database = database,
    Columns = new [] { new Column {
        Name = "col1",
        Type = Schema.STRING
    }, new Column {
        Name = "col2",
        Type = Schema.STRING
    } },
    DataFormat = DataFormat.CSV
});

var synthesizer = (DefaultStackSynthesizer)stack.Synthesizer;
new CfnDataLakeSettings(this, "DataLakeSettings", new CfnDataLakeSettingsProps {
    Admins = new [] { new DataLakePrincipalProperty {
        DataLakePrincipalIdentifier = stack.FormatArn(new ArnComponents {
            Service = "iam",
            Resource = "role",
            Region = "",
            Account = accountId,
            ResourceName = "Admin"
        })
    }, new DataLakePrincipalProperty {
        // The CDK cloudformation execution role.
        DataLakePrincipalIdentifier = synthesizer.CloudFormationExecutionRoleArn.Replace("${AWS::Partition}", "aws")
    } }
});

var tag = new CfnTag(this, "Tag", new CfnTagProps {
    CatalogId = accountId,
    TagKey = tagKey,
    TagValues = tagValues
});

var lfTagPairProperty = new LFTagPairProperty {
    CatalogId = accountId,
    TagKey = tagKey,
    TagValues = tagValues
};

var tagAssociation = new CfnTagAssociation(this, "TagAssociation", new CfnTagAssociationProps {
    LfTags = new [] { lfTagPairProperty },
    Resource = new ResourceProperty {
        TableWithColumns = new TableWithColumnsResourceProperty {
            DatabaseName = database.DatabaseName,
            ColumnNames = new [] { "col1", "col2" },
            CatalogId = accountId,
            Name = table.TableName
        }
    }
});

tagAssociation.Node.AddDependency(tag);
tagAssociation.Node.AddDependency(table);
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var stack Stack
var accountId string

tagKey := "aws"
tagValues := []*string{
	"dev",
}

database := awscdk.NewDatabase(this, jsii.String("Database"))

table := awscdk.NewS3Table(this, jsii.String("Table"), &S3TableProps{
	Database: Database,
	Columns: []Column{
		&Column{
			Name: jsii.String("col1"),
			Type: awscdk.Schema_STRING(),
		},
		&Column{
			Name: jsii.String("col2"),
			Type: awscdk.Schema_STRING(),
		},
	},
	DataFormat: awscdk.DataFormat_CSV(),
})

synthesizer := stack.Synthesizer.(DefaultStackSynthesizer)
awscdk.NewCfnDataLakeSettings(this, jsii.String("DataLakeSettings"), &CfnDataLakeSettingsProps{
	Admins: []interface{}{
		&DataLakePrincipalProperty{
			DataLakePrincipalIdentifier: stack.FormatArn(&ArnComponents{
				Service: jsii.String("iam"),
				Resource: jsii.String("role"),
				Region: jsii.String(""),
				Account: accountId,
				ResourceName: jsii.String("Admin"),
			}),
		},
		&DataLakePrincipalProperty{
			// The CDK cloudformation execution role.
			DataLakePrincipalIdentifier: synthesizer.cloudFormationExecutionRoleArn.replace(jsii.String("${AWS::Partition}"), jsii.String("aws")),
		},
	},
})

tag := awscdk.NewCfnTag(this, jsii.String("Tag"), &CfnTagProps{
	CatalogId: accountId,
	TagKey: jsii.String(TagKey),
	TagValues: TagValues,
})

lfTagPairProperty := &LFTagPairProperty{
	CatalogId: accountId,
	TagKey: jsii.String(TagKey),
	TagValues: TagValues,
}

tagAssociation := awscdk.NewCfnTagAssociation(this, jsii.String("TagAssociation"), &CfnTagAssociationProps{
	LfTags: []interface{}{
		lfTagPairProperty,
	},
	Resource: &ResourceProperty{
		TableWithColumns: &TableWithColumnsResourceProperty{
			DatabaseName: database.databaseName,
			ColumnNames: []*string{
				jsii.String("col1"),
				jsii.String("col2"),
			},
			CatalogId: accountId,
			Name: table.tableName,
		},
	},
})

tagAssociation.Node.AddDependency(tag)
tagAssociation.Node.AddDependency(table)
```

## Properties

- `lfTags`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnTagAssociation.LFTagPairProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lakeformation.CfnTagAssociation.LFTagPairProperty.html)[] (required) — A structure containing an LF-tag key-value pair.

- `resource`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnTagAssociation.ResourceProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lakeformation.CfnTagAssociation.ResourceProperty.html) (required) — UTF-8 string (valid values: `DATABASE | TABLE` ).

  The resource for which the LF-tag policy applies.
