1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

別のAWSアカウントでサブドメインを使う(CDK)

Posted at

(※2023-10-18に書いた個人ブログの転記です。)

概要

別のAWSアカウントで管理しているドメインのサブドメインを、別のAWSアカウントで使いたい。そんな時は、サブドメインを別のAWSアカウントのHosted Zoneに権限委譲すれば良い。それをCDKで行う手順をまとめる。

例として、以下のような状態を想定する。

  • AWSアカウント1(ドメインを管理している)
    • masatora.com
  • AWSアカウント2(委譲先)
    • stg.masatora.com←使いたいサブドメイン

手順とCDK

① AWSアカウント2(委譲先)でホストゾーンを作成する

private createBuyerAJAVisionZone() {
    return new route53.PublicHostedZone(this, 'HostedZone', {
        zoneName: 'stg.masatora.com',
    })
}

② 1で作成されたホストゾーンのNSレコードの値をコピー
③ AWSアカウント1(ドメインを管理している)でNSレコードを作成する

new route53.NsRecord(this, 'NsRecord', {
    zone: hostedZone,
    recordName: 'stg',
    values: [
    // ここに2でコピーしたNSレコードの値を入れる(4つある。追加も削除もせず全部入れることを推奨
    ],
})

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?