Skip to main content
Version: v1

如何使用 AWS VPC Peering ?

AWS VPC Peering 可以讓兩個不同的 VPC 透過 Private IP 連結,這樣可以很快速的設定防火牆在 Canner Enterprise 在不需要把 RDS/EC2 讓公開網路存取。在開始之前確定你的需求符合 VPC peering 限制.

首先,你需要確定 Canner Enterprise 以及你的資料來源的 VPC 已經存在。這裡假設你的 VPC 資訊如下:

(請確定 VPC 的資料換成你自己的 VPC 資訊,以下資訊只是給 demo 使用)

Notice: CIDRs 的兩個 VPCs 不可以相同。

  • Canner Enterprise VPC
ID: vpc-db3e09bc
CIDR: 172.31.0.0/16
Account: 365545700901
  • DataSource VPC
ID: vpc-08279f19bf4d9f74a
CIDR: 10.3.0.0/16
Account: 956019317291

我們要讓 Canner Enterprise VPC 能夠透過 EC2 instance 連線到 DataSoruce VPC.

在 Canner Enterprise 上的 VPC

  1. 到 VPC - Peer Connections 的畫面,點擊 Create Peering Connection.

1_Peering_Connections___VPC_Management_Console

  1. 創立 peering connection request.
    • 2.1 定義 peering connection 的新名稱。
    • 2.2 選擇 Canner Enterprise 的 VPC。
    • 2.3 填寫 account id with the account id of data source VPC.
    • 2.4 [optional] 如果兩個 VPC 在兩個不同的 Region 的話要選擇
    • 2.5 填寫 data source VPC 的 VPC id。

2_Create_Peering_Connection___VPC_Management_Console

  1. 設定 Route table.
    • 3.1 Navigate to VPC > Route Tables.
    • 3.2 Choose the route tables of VPC.
    • 3.3 Navigate to Routes tab.
    • 3.4 Click Edit routes.

3_Route_Tables___VPC_Management_Console

  1. Add route, use data source VPC CIDR as the destination, choose peering connection we created as target.

4_Edit_routes___VPC_Management_Console

在資料源上的 VPC

  1. Navigate to VPC > Peering Connections, choose and accept the request we created from Canner VPC.

5_Peering_Connections___VPC_Management_Console

  1. Navigate to VPC > Route Tables, choose the route tables of VPC, then click Edit routes.

6_Route_Tables___VPC_Management_Console

  1. Add route, use Canner Enterprise VPC CIDR as the destination, choose peering connection we created as target.

7_Edit_routes___VPC_Management_Console

  1. Update security groups roles of your EC2/RDS, accept connection from Canner Enterprise VPC CIDR and specify target port.

8_EC2_Management_Console

所有設定完成後,Canner Enterprise 會使用私有 IP 的 instance node 來獲取資料從你的資料來源。