0.0.18 • Published 2 days ago

@fallobst22/cdk-cross-account-route53 v0.0.18

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 days ago

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
0.0.18

2 days ago

0.0.17

9 days ago

0.0.16

16 days ago

0.0.15

23 days ago

0.0.14

30 days ago

0.0.13

1 month ago

0.0.12

1 month ago

0.0.11

2 months ago

0.0.10

2 months ago

0.0.9

2 months ago

0.0.8

2 months ago

0.0.5

2 months ago

0.0.7

2 months ago

0.0.6

2 months ago

0.0.3

2 months ago

0.0.4

2 months ago

0.0.2

2 months ago

0.0.1

5 months ago

0.0.0

5 months ago