1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CloudFormation で Route53 に CloudFront のエイリアスレコードを作成する

Posted at

CloudFormation で Route53 に CloudFront のエイリアスレコードを作成しようとした時にエラーが出てしまい、 エラーメッセージでググったら1 CloudFront では作成できないから管理コンソールから作成したという古い記事 が最上位に出てきて諦めかけましたが、実際にはできたので記事に残しておきます。

エラーメッセージ

Invalid Resource Record: FATAL problem: ARRDATAIllegalIPv4Address (Value is not a valid IPv4 address) encountered with 'abcdefghijkmn.cloudfront.net'

誤ったテンプレート

  Route53RecordSet:
    Type: AWS::Route53::RecordSet
    Properties:
      Name: '*.example.com'
      Type: A
      ResourceRecords:
        - abcdefghijkmn.cloudfront.net
      TTL: 300
      HostedZoneId: ABCDEFGHIJKLMN

正しいテンプレート

  Route53RecordSet:
    Type: AWS::Route53::RecordSet
    Properties:
      Name: '*.example.com'
      Type: A
      AliasTarget:
        DNSName: abcdefghijkmn.cloudfront.net
        HostedZoneId: Z2FDTNDATAQYW2 # 固定値
      HostedZoneId: ABCDEFGHIJKLMN

ResourceRecords で指定するのではなくて、 AliasTarget で指定する必要があります。
また、 HostedZoneId は CloudFront を指定する場合には Z2FDTNDATAQYW2 固定2になります。

  1. 2021 年 5 月時点

  2. AWS::Route53::RecordSet AliasTarget のドキュメント

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?