はじめに
同アカウントでのリージョン間ピアリング接続をCloudFormationで構築した際に、少しハマったため紹介します。
リージョンの明示
リクエスタ:ap-northeast-1
→スタックをap-northeast-1で作成
アクセプタ:ap-northeast-3
→テンプレート側でPeerRegionの指定をしないと、自動では判断してくれない
同一アカウント内ピアリング接続の承諾
コンソール:アクセプタ(大阪リージョン)側で、ピアリング接続の承諾が必須
CloudFormation:自動でactiveになり、承諾は不要
テンプレート例
AWSTemplateFormatVersion: 2010-09-09
Description: VPC Peering Connection
Resources:
VpcPeeringConnection:
Type: AWS::EC2::VPCPeeringConnection
Properties:
VpcId: hogehoge # リクエスタ
PeerVpcId: hogehoge # アクセプタ
PeerRegion: ap-northeast-3 # アクセプタリージョン
Outputs:
VpcPeeringConnectionId:
Description: Peering Connection ID
Value: !Ref VpcPeeringConnection
Export:
Name: hogehoge