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.

【Route53】CloudFormationでシンプルルーティングから加重ルーティングに瞬断無しで変更する方法

Last updated at Posted at 2022-04-20

状況としてはこんな感じです。
このようなシンプルルーティングを、

  Route53RecordSetApi:
    Type: 'AWS::Route53::RecordSet'
    Properties:
      HostedZoneId: 'example.com.'
      Name: 'mysite.example.com.'
      Type: 'CNAME'
      TTL: '300'
      ResourceRecords: 
        - 'example-ec2.amazonaws.com'

こんな加重ルーティングにしたい。瞬断無しで。

  Route53RecordSetGroupApi:
    Type: 'AWS::Route53::RecordSetGroup'
    Properties:
      HostedZoneId: 'example.com.'
      RecordSets:
      - Name: 'mysite.example.com.'
        Type: 'CNAME'
        TTL: '300'
        SetIdentifier: 'Frontend One'
        Weight: 60
        ResourceRecords: 
          - 'example-ec2.amazonaws.com'
      - Name: mysite.example.com.
        Type: 'CNAME'
        TTL: '300'
        SetIdentifier: 'Frontend Two'
        Weight: 40
        ResourceRecords: 
          - 'example-ec2-larger.amazonaws.com'

結論、瞬断無しではできません

それは以下の2つの事実があるからです。

事実1:リソースタイプが違う
シンプルルーティングと加重ルーティングは異なるリソースタイプを用いています。
それぞれ AWS::Route53::RecordSetAWS::Route53::RecordSetGroup です。

事実2:同じ名前とタイプを持つレコードを同時に登録できない
上の例だとシンプルと加重でレコード名とタイプが重複しています。
これらが同時に存在することはできないですよね。

そのため、

  1. シンプルルーティングを削除する変更セットを作成 → 適用
  2. 加重ルーティングを作成する変更セットを作成 → 適用

の順に作業しなければなりません。
1 と 2 の間でレコードが存在しない時間ができるため、一時的に名前解決ができなくなります。
(AWS サポートにも問い合わせてみましたが同じ回答でした)

ちなみに

マネージドコンソールからであればシンプルルーティングから加重ルーティングへ、
既存レコードを削除することなく変更できました。

一旦 CloudFormation スタックからレコードを切り離して手動で変更し、
後からインポートすればいいのでは?と思いましたが、こちらにあるように、
AWS::Route53::RecordSetGroup はインポート非対応でした。

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?