搭配使用 CreateInternetGateway 與 CLI - AWS SDK 程式碼範例

AWS文件開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例。

搭配使用 CreateInternetGateway 與 CLI

下列程式碼範例示範如何使用 CreateInternetGateway

動作範例是大型程式的程式碼摘錄,必須在內容中執行。您可以在下列程式碼範例的內容中看到此動作:

CLI
AWS CLI

建立網際網路閘道

以下 create-internet-gateway 範例會建立具有標籤 Name=my-igw 的網際網路閘道。

aws ec2 create-internet-gateway \ --tag-specifications ResourceType=internet-gateway,Tags=[{Key=Name,Value=my-igw}]

輸出:

{ "InternetGateway": { "Attachments": [], "InternetGatewayId": "igw-0d0fb496b3994d755", "OwnerId": "123456789012", "Tags": [ { "Key": "Name", "Value": "my-igw" } ] } }

如需詳細資訊,請參閱《Amazon VPC 使用者指南》中的網際網路閘道

PowerShell
Tools for PowerShell V4

範例 1:此範例會建立網際網路閘道。

New-EC2InternetGateway

輸出:

Attachments InternetGatewayId Tags ----------- ----------------- ---- {} igw-1a2b3c4d {}
  • 如需 API 詳細資訊,請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》中的 CreateInternetGateway

Tools for PowerShell V5

範例 1:此範例會建立網際網路閘道。

New-EC2InternetGateway

輸出:

Attachments InternetGatewayId Tags ----------- ----------------- ---- {} igw-1a2b3c4d {}
  • 如需 API 詳細資訊,請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》中的 CreateInternetGateway