@fallobst22/cdk-cross-account-route53

中文文档
0.0.137发布于 2026/11/01Apache-2.0TypeScriptCommonJS零依赖构建来源已验证

CDK Construct to allow creation of Route 53 records in a different account

原始使用文档
文档目录10 节
  1. Getting started
  2. CrossAccountRoute53Role
  3. Initializer
  4. Construct Props
  5. CrossAccountRoute53RolePropsRecords
  6. CrossAccountRoute53RecordSet
  7. Initializer
  8. Construct Props
  9. Development Status
  10. Development

AWS CDK Cross Account Route53

AWS CDK Constructs that define:

  • IAM role that can be used to allow discrete Route53 Record changes
  • Cross Account Record construct to create Route53 cross account Route53 records

These constructs allow you to create Route53 records where the zone exists in a separate AWS account to the Cloudformation Stack.

Getting started

yarn add @fallobst22/cdk-cross-account-route53

First create the role in the stack for the AWS account which contains the hosted zone.

// DNS Stack
const zone = new route53.PublicHostedZone(this, 'HostedZone', {
  zoneName: 'example.com',
});

new CrossAccountRoute53Role(this, 'WebRoute53Role', {
  roleName: 'WebRoute53Role',
  assumedBy: new iam.AccountPrincipal('22222222'), // Web Stack Account
  zone,
  records: [{ domains: ['www.example.com'] }],
 });

Then in the child stack create the records

const hostedZoneId = 'Z12345'; // ID of the zone in the other account

const distribution = new cloudfront.Distribution(this, 'Distribution', {
  domainNames: ['example.com'],
});

new CrossAccountRoute53RecordSet(this, 'ARecord', {
  delegationRoleName: 'WebRoute53Role',
  delegationRoleAccount: '111111111', // The account that contains the zone and role
  hostedZoneId,
  resourceRecordSets: [{
    Name: `example.com`,
    Type: 'A',
    AliasTarget: {
      DNSName: distribution.distributionDomainName,
      HostedZoneId: 'Z2FDTNDATAQYW2', // Cloudfront Hosted Zone Id
      EvaluateTargetHealth: false,
    },
  }],
});

CrossAccountRoute53Role

Initializer

new CrossAccountRoute53Role(scope: Construct, id: string, props: CrossAccountRoute53RoleProps)

Parameters

  • scope Construct
  • id string
  • props CrossAccountRoute53RoleProps

Construct Props

NameTypeDescription
roleNamestringThe role name
assumedByiam.IPrincipalThe principals that are allowed to assume the role
zoneroute53.IHostedZoneThe hosted zone.
recordsCrossAccountRoute53RolePropsRecord[]The records that can be created by this role

CrossAccountRoute53RolePropsRecords

NameTypeDescription
domainNamesstring | string[]The names of the records that can be created or changed
typesroute53.RecordType[]The typepsof records that can be created. Default ['A', 'AAAA']
actions'CREATE' | 'UPSERT' | 'DELETE'The allowed actions. Default ['CREATE', 'UPSERT', 'DELETE']

CrossAccountRoute53RecordSet

Initializer

new CrossAccountRoute53RecordSet(scope: Construct, id: string, props: CrossAccountRoute53RecordSetProps)

Parameters

  • scope Construct
  • id string
  • props CrossAccountRoute53RecordSet

Construct Props

NameTypeDescription
delegationRoleNamestringThe role name created in the account with the hosted zone
delegationRoleAccountstringThe account identfier of the account with the hosted zone
hostedZoneIdstringThe hosted zoned id
resourceRecordSetsRoute53.ResourceRecordSetsThe changes to be applied. These are in the same format as taken by ChangeResourceRecordSets Action

Development Status

These constructs will stay in v0.x.x for a while, to allow easier bug fixing & breaking changes if absolutely needed. Once bugs are fixed (if any), the constructs will be published with v1 major version and will be marked as stable.

Only typescript has been tested.

Development

  • npm run build compile typescript to js
  • npm run watch watch for changes and compile
  • npm run test perform the jest unit tests

版本与发布记录

@fallobst22/cdk-cross-account-route53 共发布 137 个版本,首次发布于 2023/12/21;过去 12 个月发布了 51 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.0.137latest2026/11/012 天前
0.0.1362026/10/259 天前
0.0.1352026/10/1816 天前
0.0.1342026/10/1123 天前
0.0.1332026/10/0430 天前
0.0.1322026/09/271 个月前

关于 @fallobst22/cdk-cross-account-route53 的常见问题

@fallobst22/cdk-cross-account-route53 是什么?

CDK构造允许在不同的帐户中创建Route 53记录

如何安装 @fallobst22/cdk-cross-account-route53?

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

@fallobst22/cdk-cross-account-route53 支持 TypeScript 吗?

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

@fallobst22/cdk-cross-account-route53 支持 ESM 还是 CommonJS?

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

@fallobst22/cdk-cross-account-route53 可以商用吗?

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

@fallobst22/cdk-cross-account-route53 还在维护吗?

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