目的
- 最新技術に追従している気持ちになるため、re:Invent 2019で発表された AWS Transit Gateway Inter-Region Peering について検証する。(元々、リージョン間接続はできないのかな?と思っており、期待に応えるアップデートだったこともあり)
AWS Transit Gateway Inter-Region Peering とは(自分の理解)
- 元々Transit Gatewayの機能として、リージョン内の複数のVPCを接続することができたが、今回別リージョンのTransit Gateway同士をPeering接続し、リージョンをまたいだ接続が可能になった。
やったこと
- オハイオリージョンのVPCとアイルランドリージョンのVPCを、Transit Gateway Inter-Region Peeringを用いて接続し、それぞれのVPCにあるEC2インスタンス間でping疎通確認を行う。(2019/12時点で東京リージョンでは使用不可)
構成図
作業手順
手順概要
- 事前準備
- Ohio:VPC、subnet、インスタンスの作成
- Ireland: VPC、subnet、インスタンスの作成
- Transit Gateway(TGW)関係の設定
- Ohio: TGWの作成
- Ohio: TGW Attachment (VPC側) の作成
- Ohio: subnetのroutetableにroute追加
- Ireland: TGWの作成
- Ireland: TGW Attachment (VPC側) の作成
- Ireland: subnetのroutetableにroute追加
- Ohio: TGW Attachment (Peering) の作成
- Ireland: TGW Attachment (Peering) の承認
- Ohio: TGW Attachment (VPC側) 用routetableへのrouteの追加
- Ohio: TGW Attachment (Peering) 用routetableへのrouteの追加
- Ireland: TGW Attachment (VPC側) 用routetableへのrouteの追加
- Ireland: TGW Attachment (Peering) 用routetableへのrouteの追加
手順詳細
- Ohio: VPC、subnet、インスタンスの作成
- VPC(192.168.0.0/16)、subnet(192.168.0.0/24)を作成し、subnet内にインスタンス1を作成。
- Ireland: VPC、subnet、インスタンスの作成
- VPC(10.0.0.0/16)、subnet(10.0.0.0/24)を作成し、subnet内にインスタンス2を作成。
- Ohio: TGWの作成
- TGW(Ohio)を作成。
- Ohio: TGW Attachment (VPC側) の作成
- TGW Attachment(mksamba-att-vpc-O)を作成する。ResourceTypeはVPCを選択し、接続先としてOhioのVPCを指定する。
- Ohio: subnetのroutetableにroute追加
- subnet のroutetable に Ireland側subnet(10.0.0.0/24) への経路としてTGWを指定する。
-
Ireland: TGWの作成
- TGW(Ireland)を作成。
-
Ireland: TGW Attachment (VPC側) の作成
- TGW Attachment(mksamba-att-vpc-I)を作成する。ResourceTypeとしてVPCを選択し、接続先としてIrelandのVPCを指定する。
-
Ireland: subnetのroutetableにroute追加
- subnet のroutetable に、Ohio側subnet(192.168.0.0/24) への経路としてTGWを指定する。
-
Ohio: TGW Attachment (Peering) の作成
- TGW Attachment(mksamba-att-peer-O)を作成し、TypeとしてPeering Connection を選択し、接続先としてIrelandのTGWを指定し、接続要求を作成する。
- Ireland: TGW Attachment (Peering) の承認
- Ohioからの接続要求を承認する。
- 承認すると、Ireland側にもTGW Attachment(Ohio TGWとのpeering)が自動的に作成される。(Nameは空欄になるので追記が必要。mksamba-att-peer-I としておく。)
- Ohio: TGW Attachment (VPC側) 用routetableへのrouteの追加
- TGW Attachment (VPC側) 用のTGW routetableに対し、IrelandのVPCのsubnet(10.0.0.0/24)への経路として、 TGW Attachment(Peering)を追加する。
- Ohio: TGW Attachment (Peering) 用routetableへのrouteの追加
- TGW Attachment (Peering) 用のTGW routetableを作成し、OhioのVPCのsubnet(192.168.0.0/24)への経路として、TGW Attachment(VPC側)を追加する。
-
Ireland: TGW Attachment (VPC側) 用routetableへのrouteの追加
- TGW Attachment(VPC側)用のTGW routetable に対し、OhioのVPCのsubnet(192.168.0.0/24)への経路として、TGW Attachment(Peering)を追加する。
-
Ireland: TGW Attachment (Peering) 用routetableへのrouteの追加
- TGW Attachment (Peering) 用のTGW routetableを作成し、IrelandのVPCのsubnet(10.0.0.0/24)への経路として、TGW Attachment(VPC側)を追加する。
結果確認
- インスタンス1(Ohio)から、TGW Inter-Region Peering 経由でのインスタンス2(Ireland)へのping
[ec2-user@ip-192-168-0-218 ~]$ ping 10.0.0.197
PING 10.0.0.197 (10.0.0.197) 56(84) bytes of data.
64 bytes from 10.0.0.197: icmp_seq=1 ttl=253 time=95.9 ms
64 bytes from 10.0.0.197: icmp_seq=2 ttl=253 time=95.4 ms
64 bytes from 10.0.0.197: icmp_seq=3 ttl=253 time=95.3 ms
64 bytes from 10.0.0.197: icmp_seq=4 ttl=253 time=95.4 ms
64 bytes from 10.0.0.197: icmp_seq=5 ttl=253 time=95.3 ms
64 bytes from 10.0.0.197: icmp_seq=6 ttl=253 time=95.3 ms
64 bytes from 10.0.0.197: icmp_seq=7 ttl=253 time=95.3 ms
64 bytes from 10.0.0.197: icmp_seq=8 ttl=253 time=95.4 ms
64 bytes from 10.0.0.197: icmp_seq=9 ttl=253 time=95.3 ms
64 bytes from 10.0.0.197: icmp_seq=10 ttl=253 time=95.4 ms
^C
--- 10.0.0.197 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9013ms
rtt min/avg/max/mdev = 95.312/95.447/95.985/0.359 ms
[ec2-user@ip-192-168-0-218 ~]$
- インスタンス1(Ohio)から、Internet経由でのインスタンス2(Ireland)へのping (比較のため参考)
[ec2-user@ip-192-168-0-218 ~]$ ping 34.200.11.xxx
PING 34.200.11.xxx (34.200.11.xxx) 56(84) bytes of data.
64 bytes from 34.200.11.xxx: icmp_seq=1 ttl=229 time=95.6 ms
64 bytes from 34.200.11.xxx: icmp_seq=2 ttl=229 time=95.6 ms
64 bytes from 34.200.11.xxx: icmp_seq=3 ttl=229 time=95.7 ms
64 bytes from 34.200.11.xxx: icmp_seq=4 ttl=229 time=97.2 ms
64 bytes from 34.200.11.xxx: icmp_seq=5 ttl=229 time=95.6 ms
64 bytes from 34.200.11.xxx: icmp_seq=6 ttl=229 time=95.7 ms
64 bytes from 34.200.11.xxx: icmp_seq=7 ttl=229 time=95.6 ms
64 bytes from 34.200.11.xxx: icmp_seq=8 ttl=229 time=95.6 ms
64 bytes from 34.200.11.xxx: icmp_seq=9 ttl=229 time=95.6 ms
64 bytes from 34.200.11.xxx: icmp_seq=10 ttl=229 time=95.6 ms
^C
--- 34.200.11.xxx ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9016ms
rtt min/avg/max/mdev = 95.601/95.804/97.219/0.530 ms
[ec2-user@ip-192-168-0-218 ~]$
- 無事、Transit Gateway Inter-Region Peering 経由でpingできることを確認できた。
- 比較のため、インスタンス1/2の両方にEIPを付与し、Internet経由としてpingした。いずれにしろAWSのネットワークを通るのか、応答速度はあまり変わらなかったが、ttlの数値はだいぶ異なるので、当然ながら経路は異なる様子。
所感
- TGW Attachment毎にroutetableを付けるという概念を理解するのに少し時間がかかった。
- 二つのVPCをつなげることはできたが、詳細設定(propagations等)の理解が不十分なため、引き続き検証してみたい。
参考
-
Transit Gatewayのリージョン間接続を試してみた #reinvent
- クラスメソッド社のブログ。ここを見てやり方を確認し、自分なりに再整理した。