LoginSignup
2
0

More than 1 year has passed since last update.

AWS Transit Gateway 使ってみた

Last updated at Posted at 2022-10-09

概要

以下のように異なる 2 つの VPC にインスタンスを作成し、Transit Gateway を経由して疎通確認を行います。

image.png

手順

準備

あらかじめ、以下のリソースを作成しておきます。

VPC Subnet Route Table IGW
name CIDR name AZ CIDR name name
tgw-demo-vpc-1 10.0.0.0/24 tgw-demo-subnet-1 ap-northeast-1a 10.0.0.0/28 tgw-demo-rt-1 tgw-demo-igw-1
tgw-demo-vpc-2 10.0.1.0/24 tgw-demo-subnet-2 ap-northeast-1c 10.0.1.0/28 tgw-demo-rt-2 tgw-demo-igw-2

Transit Gateway の作成

名前のみ入力し、その他はデフォルトで進めます。ASN はデフォルトで 64512 が割り当てられます。

1.png

「Transit Gateway を作成」をクリックします。

2.png

アタッチメントの作成

名前、Transit Gateway ID を入力します。アタッチメントには VPC を選択します。

3.png

アタッチメントタイプを作成する VPC、サブネットを選択します。

4.png

ルートテーブルの編集

ルートテーブルに自分のサブネットに作成したアタッチメントへのルートを追加します。

5.png

セキュリティグループルールの作成

以下はインスタンス 1 に関連付けるセキュリティグループになります。

6.png

以下はインスタンス 2 に関連付けるセキュリティグループになります。

7.png

動作確認

インスタンス 1

[ec2-user@ip-10-0-0-5 ~]$ ping -c 4 10.0.1.14
PING 10.0.1.14 (10.0.1.14) 56(84) bytes of data.
64 bytes from 10.0.1.14: icmp_seq=1 ttl=254 time=2.13 ms
64 bytes from 10.0.1.14: icmp_seq=2 ttl=254 time=1.87 ms
64 bytes from 10.0.1.14: icmp_seq=3 ttl=254 time=1.87 ms
64 bytes from 10.0.1.14: icmp_seq=4 ttl=254 time=1.88 ms

--- 10.0.1.14 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 1.875/1.943/2.138/0.112 ms

インスタンス 2

[ec2-user@ip-10-0-1-14 ~]$ ping -c 4 10.0.0.5
PING 10.0.0.5 (10.0.0.5) 56(84) bytes of data.
64 bytes from 10.0.0.5: icmp_seq=1 ttl=254 time=2.00 ms
64 bytes from 10.0.0.5: icmp_seq=2 ttl=254 time=1.87 ms
64 bytes from 10.0.0.5: icmp_seq=3 ttl=254 time=1.87 ms
64 bytes from 10.0.0.5: icmp_seq=4 ttl=254 time=1.85 ms

--- 10.0.0.5 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 1.859/1.905/2.008/0.073 ms

CloudFormation サンプルテンプレ―ト

サンプルテンプレートを作成しました。

以下のパラメータは、疎通確認用にログインするインスタンス 1、インスタンス 2に関連付けるセキュリティグループのインバウンドルールに設定する SSH 接続元 IP アドレスを入力します。

8.png

参考記事

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