@cdklabs/cdk-construct-connect-datalake

中文文档
0.0.33发布于 2026/11/03Apache-2.0TypeScriptCommonJS构建来源已验证近 30 天下载 2016

Construct library for Amazon Connect Data Lake

原始使用文档
文档目录17 节
  1. Usage
  2. Prerequisites
  3. Installation
  4. Basic Usage
  5. Cross-Account Configuration
  6. Multiple Instances
  7. API Reference
  8. DataLakeAccess
  9. DataType Enum
  10. Resources Created
  11. Infrastructure Components
  12. Deployment Workflow
  13. Limitations
  14. Troubleshooting
  15. Support
  16. Contributing
  17. License

Amazon Connect Data Lake CDK Construct

An AWS Cloud Development Kit (CDK) construct that enables access to Amazon Connect analytics data lake. This solution automates the complete Connect Data Lake setup process, eliminating the need for manual configuration or custom CloudFormation templates.

The construct uses a Lambda-backed custom resource to manage the deployment process. It handles associating Connect datasets, accepting RAM resource shares, granting Lake Formation permissions, and creating resource link tables in a centralized Glue database—with support for same-account and cross-account configurations.

Usage

Prerequisites

Installation

Install the construct library in your CDK project directory:

TypeScript/JavaScript
npm install @cdklabs/cdk-construct-connect-datalake
Python
pip install cdklabs.cdk-construct-connect-datalake
Java

Add the following dependency to your pom.xml:

<dependency>
  <groupId>io.github.cdklabs</groupId>
  <artifactId>cdk-construct-connect-datalake</artifactId>
  <version>VERSION</version>
</dependency>
.NET
dotnet add package Cdklabs.CdkConstructConnectDatalake
Go
go get github.com/cdklabs/cdk-construct-connect-datalake-go/cdkconstructconnectdatalake

Basic Usage

Add the DataLakeAccess construct to a CDK stack deployed in the same AWS account and region as your Amazon Connect instance.

import { DataLakeAccess, DataType } from '@cdklabs/cdk-construct-connect-datalake';

new DataLakeAccess(this, 'DataLakeAccess', {
  instanceId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', // Your Connect instance ID
  datasetIds: [
    DataType.CONTACT_RECORD,
    'contact_statistic_record',
  ],
});

Important: When deploying alongside a Connect instance in the same stack, add a dependency to the construct:

Example
import { DataLakeAccess, DataType } from '@cdklabs/cdk-construct-connect-datalake';
import { CfnInstance } from 'aws-cdk-lib/aws-connect';

const connectInstance = new CfnInstance(this, 'ConnectInstance', {
  identityManagementType: 'CONNECT_MANAGED',
  instanceAlias: 'my-instance',
  attributes: {
    inboundCalls: true,
    outboundCalls: true,
  },
});

const dataLake = new DataLakeAccess(this, 'DataLakeAccess', {
  instanceId: connectInstance.attrId,
  datasetIds: [DataType.CONTACT_RECORD],
});

// Ensure data lake resources are deleted before the Connect instance
dataLake.node.addDependency(connectInstance);

Cross-Account Configuration

Configure the construct to create data lake resources in a different AWS account by specifying targetAccountId and targetAccountRoleArn. The construct assumes the target role to accept the RAM resource share(s) and create Glue resources in that account.

import { DataLakeAccess, DataType } from '@cdklabs/cdk-construct-connect-datalake';

new DataLakeAccess(this, 'DataLakeAccess', {
  instanceId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
  datasetIds: [
    DataType.CONTACT_RECORD,
    'contact_statistic_record',
  ],

  // Target account where the resources are created
  targetAccountId: '123456789012', 
  
  // IAM role in the target account for cross-account role assumption
  targetAccountRoleArn: "arn:aws:iam::123456789012:role/RoleName",
});

Multiple Instances

Enable data lake access for multiple Connect instances by creating a separate construct for each. A dependency should be added between them to ensure sequential deployment, preventing conflicts from concurrent operations.

import { DataLakeAccess, DataType } from '@cdklabs/cdk-construct-connect-datalake';

// First Connect instance data lake setup
const dataLake1 = new DataLakeAccess(this, 'DataLakeAccess1', {
  instanceId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
  datasetIds: [
    DataType.CONTACT_RECORD,
    DataType.AGENT_STATISTIC_RECORD,
  ],
});

// Second Connect instance data lake setup 
const dataLake2 = new DataLakeAccess(this, 'DataLakeAccess2', {
  instanceId: 'yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy',
  datasetIds: [
    DataType.CONTACT_RECORD,
    DataType.CONTACT_FLOW_EVENTS,
  ],
});

// Create dependency to ensure sequential deployment
dataLake2.node.addDependency(dataLake1);

API Reference

DataLakeAccess

The main construct class for setting up Amazon Connect Data Lake integration.

Properties:

  • instanceId (string): Amazon Connect instance ID
  • datasetIds (Array<string | DataType>): Array of dataset IDs to associate. Use DataType enum values or string literals for datasets not yet in the enum.
  • targetAccountId? (string): Target AWS account ID receiving resources (optional)
  • targetAccountRoleArn? (string): IAM role ARN in the target account for cross-account role assumption (optional)

DataType Enum

For a list of supported dataset types, see the API Documentation.

Resources Created

This construct creates the following AWS resources:

Infrastructure Components

  • CloudFormation Custom Resource Provider: Framework for managing custom resource lifecycle

  • Lambda Function: Custom resource handler that orchestrates the data lake setup

  • IAM Role: Execution role with permissions for Connect, RAM, Glue, and Lake Formation operations

    Show IAM permissions
    • connect:BatchAssociateAnalyticsDataSet
    • connect:AssociateAnalyticsDataSet
    • connect:BatchDisassociateAnalyticsDataSet
    • connect:DisassociateAnalyticsDataSet
    • connect:ListAnalyticsDataAssociations
    • connect:ListAnalyticsDataLakeDataSets
    • connect:ListInstances
    • ds:DescribeDirectories
    • ram:AcceptResourceShareInvitation
    • ram:GetResourceShareInvitations
    • ram:GetResourceShares
    • glue:CreateDatabase
    • glue:CreateTable
    • glue:DeleteDatabase
    • glue:DeleteTable
    • glue:GetDatabase
    • glue:GetTables
    • lakeformation:GetDataLakeSettings
    • lakeformation:PutDataLakeSettings
    • cloudformation:DescribeStacks
    • sts:AssumeRole (for cross-account setups only)

Deployment Workflow

The construct performs the following steps during deployment:

Deployment Workflow

  1. Dataset Association: Associates the specified datasets for an Amazon Connect instance with the target account
  2. Database Creation: Creates the connect_datalake_database Glue database
  3. Lake Formation Setup: Configures the Lambda execution role (or assumed role for cross-account) as a data lake administrator
  4. Resource Share Acceptance: Accepts the RAM resource share invitation(s). Multiple dataset associations often consolidate into a single RAM resource share
  5. Table Creation: Creates resource link tables for each dataset, enabling queries via Amazon Athena

When deploying to the same account as the Connect instance, all steps execute within that account. For cross-account configurations, steps 2-5 execute in the target account.

Limitations

  • Table Naming: Resource link tables created by this construct are named using the format {datasetId}_{dataCatalogId}
  • Region Support: The construct must be deployed in the same AWS region and account as the Amazon Connect instance. For cross-account configurations, resources are created in the target account within the same region
  • Shared Database: The connect_datalake_database Glue database is shared across all deployments of this construct in an account

Troubleshooting

Partial failures during deployment

  • If some workflow steps fail during create or update operations, the stack deployment will still show as successful. Error details for these partial failures are available in the CloudFormation stack outputs.

RAM resource share has expired

  • Resource shares for new dataset associations can consolidate into existing AWS RAM shares, even if expired. Delete each construct that references the target account, confirm the associated resources are removed, then redeploy using the original construct definitions.

Failure to update Lake Formation permissions due to invalid principal

  • IAM roles that have been deleted but not removed from Lake Formation principals will be considered invalid. Remove the principal causing this error from Lake Formation and redeploy the construct.

Resources are unable to be removed after a Connect instance has been deleted

  • Constructs of this type must be deleted prior to deleting the instance, as cleanup after instance deletion is currently not supported. A GitHub issue can be raised if assistance removing these resources is required.

Support

For issues and questions:

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

This project is licensed under the Apache-2.0 License.

版本与发布记录

@cdklabs/cdk-construct-connect-datalake 共发布 34 个版本,首次发布于 2026/03/03;过去 12 个月发布了 34 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.33latest2026/11/036 天前
0.0.322026/10/2713 天前
0.0.312026/10/2020 天前
0.0.302026/10/1327 天前
0.0.292026/10/061 个月前
0.0.282026/09/291 个月前

关于 @cdklabs/cdk-construct-connect-datalake 的常见问题

@cdklabs/cdk-construct-connect-datalake 是什么?

Construct library for Amazon Connect Data Lake

如何安装 @cdklabs/cdk-construct-connect-datalake?

在项目目录运行 npm install @cdklabs/cdk-construct-connect-datalake,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:constructs(^10.5.1)、aws-cdk-lib(^2.240.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cdklabs/cdk-construct-connect-datalake 支持 TypeScript 吗?

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

@cdklabs/cdk-construct-connect-datalake 支持 ESM 还是 CommonJS?

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

@cdklabs/cdk-construct-connect-datalake 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 18.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cdklabs/cdk-construct-connect-datalake 可以商用吗?

@cdklabs/cdk-construct-connect-datalake 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@cdklabs/cdk-construct-connect-datalake 的下载量有多少?

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

@cdklabs/cdk-construct-connect-datalake 还在维护吗?

最新版本 0.0.33 发布于 2026/11/03(6 天前);至今共发布 34 个版本,其中过去 12 个月发布了 34 个;首次发布于 2026/03/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。