# @aws-mdaa/lakeformation-tags-l3-construct 中文文档

规范地址：https://npmcn.com/package/%40aws-mdaa/lakeformation-tags-l3-construct/

版本：1\.10\.0
npm 元数据更新时间：2026-11-07T13:49:52.175Z
中文译文更新时间：2026-11-07T20:55:19.130Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40aws-mdaa/lakeformation-tags-l3-construct
原文对照：https://npmcn.com/package/%40aws-mdaa/lakeformation-tags-l3-construct/?lang=original
项目主页：https://github.com/aws/modern-data-architecture-accelerator#readme
源码仓库：https://github.com/aws/modern-data-architecture-accelerator

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：327 kB，11 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：5 个
- peer 依赖：constructs 10\.6\.0，aws-cdk-lib 2\.263\.0，@aws-mdaa/construct 1\.10\.0，@aws-mdaa/l3-construct 1\.10\.0
- 首次发布：2026-02-04T08:24:32.477Z
- 最新版本发布：2026-11-07T13:49:51.995Z
- 近 30 天下载量：2607（2026-10-08 至 2026-11-06，npm 官方下载统计）
- 已发布版本数：8（近 12 个月 8 个）

## 中文简介

MDAA 湖形标记 L3 构造

## 安装

```sh
npm install @aws-mdaa/lakeformation-tags-l3-construct
```

也可以使用：`pnpm add @aws-mdaa/lakeformation-tags-l3-construct`、`yarn add @aws-mdaa/lakeformation-tags-l3-construct`、`bun add @aws-mdaa/lakeformation-tags-l3-construct`

## README

# 湖形成标记 L3 构造

这个软件包为管理AWS湖形成标记及其关联提供了两种构造,并提供了基于标记的访问控制(TBAC)的数据资源.

## 概览

Lake Formation tags(LF-Tags)是可附加到数据目录资源(数据库,表格,列)中的密钥值对. 这些标签允许基于属性的访问控制,允许您根据标签表达式而不是单个资源授予权限.

此套件将标签创建从标签关联区分为两个不同的构件:

-   **湖边建筑**: 在账户一级创建 LF- Tags
-   **湖边论坛协会L3 建设**: 具有数据库和表格的现有标签

## 构造

### 湖边建筑

在账户级别创建 LF- Tags 。 这些标记定义了基于标记的访问控制词汇,可以被多数据库和表格重复使用.

#### 使用量

```typescript
import { LakeFormationTagsL3Construct } from '@aws-mdaa/lakeformation-tags-l3-construct';

const tagsConstruct = new LakeFormationTagsL3Construct(this, 'ProjectLFTags', {
  lfTags: [
    {
      tagKey: 'environment',
      tagValues: ['dev', 'test', 'prod'],
    },
    {
      tagKey: 'data_tier',
      tagValues: ['bronze', 'silver', 'gold'],
    },
  ],
});
```

#### 属性

-   `lfTags` (需要):数量 `LFTagConfig` 定义要创建的标签的对象

#### LFtag 图形

-   `tagKey` (需要):湖形成标记的密钥(名称)
-   `tagValues` ( 需要): 此标签的允许值阵列
-   `catalogId` (可选) : 创建标签的目录 ID( 默认为当前账户)

### 湖边论坛协会L3 建设

拥有数据库和表格的现有LF-Tag。 此构造假设标记已经创建 .

#### 使用量

```typescript
import { 
  LakeFormationTagsL3Construct,
  LakeFormationTagAssociationL3Construct 
} from '@aws-mdaa/lakeformation-tags-l3-construct';

// First, create the tags
const tagsConstruct = new LakeFormationTagsL3Construct(this, 'ProjectLFTags', {
  lfTags: [
    {
      tagKey: 'environment',
      tagValues: ['dev', 'test', 'prod'],
    },
    {
      tagKey: 'data_tier',
      tagValues: ['bronze', 'silver', 'gold'],
    },
  ],
});

// Then, associate tags with a database
new LakeFormationTagAssociationL3Construct(this, 'DatabaseTagAssociation', {
  databaseName: 'my-database',
  tagValues: [
    {
      tagKey: 'environment',
      tagValues: ['prod'],
    },
    {
      tagKey: 'data_tier',
      tagValues: ['gold'],
    },
  ],
  projectLevelTagsConstruct: tagsConstruct, // Ensures tags exist before association
});

// Optionally, associate tags with specific tables
new LakeFormationTagAssociationL3Construct(this, 'TableTagAssociation', {
  databaseName: 'my-database',
  tables: ['table1', 'table2'],
  tagValues: [
    {
      tagKey: 'environment',
      tagValues: ['prod'],
    },
  ],
  projectLevelTagsConstruct: tagsConstruct,
});
```

#### 属性

-   `databaseName` (需要):将标签与
-   `tagValues` (需要):数量 `LFTagConfig` 指定要关联的标签值的对象
-   `projectLevelTagsConstruct` (可选):参考创建标记的构造(用于依赖管理)
-   `tables` (可选) : 特定表格名称的组合到关联标记

## 完整示例

```typescript
import { 
  LakeFormationTagsL3Construct,
  LakeFormationTagAssociationL3Construct 
} from '@aws-mdaa/lakeformation-tags-l3-construct';

// Step 1: Create account-level tags
const tagsConstruct = new LakeFormationTagsL3Construct(this, 'OrgLFTags', {
  lfTags: [
    {
      tagKey: 'environment',
      tagValues: ['dev', 'test', 'prod'],
    },
    {
      tagKey: 'data_tier',
      tagValues: ['bronze', 'silver', 'gold'],
    },
    {
      tagKey: 'pii',
      tagValues: ['true', 'false'],
    },
  ],
});

// Step 2: Associate tags with production database
new LakeFormationTagAssociationL3Construct(this, 'ProdDatabaseTags', {
  databaseName: 'production-db',
  tagValues: [
    { tagKey: 'environment', tagValues: ['prod'] },
    { tagKey: 'data_tier', tagValues: ['gold'] },
  ],
  projectLevelTagsConstruct: tagsConstruct,
});

// Step 3: Associate tags with specific sensitive tables
new LakeFormationTagAssociationL3Construct(this, 'SensitiveTableTags', {
  databaseName: 'production-db',
  tables: ['customers', 'transactions'],
  tagValues: [
    { tagKey: 'pii', tagValues: ['true'] },
  ],
  projectLevelTagsConstruct: tagsConstruct,
});
```

## 最佳做法

1.  **关注的分离**: 在账户一级创建标签一次, 然后根据需要将其与多个资源关联
2.  **标记命名**: 对标记键使用一致的命名惯例( 如: snake case)
3.  **标记值**: 在标签创建步骤中定义所有可能的值,以确保标记的一致性
4.  **依赖关系**: 总是通过 `projectLevelTagsConstruct` 在创建协会之前确保标签存在
5.  **可续用性**: 账户级别标签可在多个数据库和表格中重复使用

## 相关构造

-   `LakeFormationTagBasedPermissionsL3Construct`: 根据 LF-Tag 表达式授予权限
-   `LakeFormationAccessControlL3Construct`: 传统资源型湖形成许可

## 常见问题

### @aws-mdaa/lakeformation-tags-l3-construct 是什么？

MDAA 湖形标记 L3 构造

### 如何安装 @aws-mdaa/lakeformation-tags-l3-construct？

在项目目录运行 npm install @aws-mdaa/lakeformation-tags-l3-construct，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：constructs（10\.6\.0）、aws-cdk-lib（2\.263\.0）、@aws-mdaa/construct（1\.10\.0）、@aws-mdaa/l3-construct（1\.10\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @aws-mdaa/lakeformation-tags-l3-construct 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @aws-mdaa/lakeformation-tags-l3-construct 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @aws-mdaa/lakeformation-tags-l3-construct 可以商用吗？

@aws-mdaa/lakeformation-tags-l3-construct 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @aws-mdaa/lakeformation-tags-l3-construct 的下载量有多少？

根据 npm 官方下载统计，@aws-mdaa/lakeformation-tags-l3-construct 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,607 次，日均约 87 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @aws-mdaa/lakeformation-tags-l3-construct 还在维护吗？

最新版本 1\.10\.0 发布于 2026/11/07（今天）；至今共发布 8 个版本，其中过去 12 个月发布了 8 个；首次发布于 2026/02/04。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

