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

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

搭配使用 AttachVpnGateway 與 CLI

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

CLI
AWS CLI

將虛擬私有閘道連接到 VPC

下列 attach-vpn-gateway 範例會將指定的虛擬私有閘道連接至指定的 VPC。

aws ec2 attach-vpn-gateway \ --vpn-gateway-id vgw-9a4cacf3 \ --vpc-id vpc-a01106c2

輸出:

{ "VpcAttachment": { "State": "attaching", "VpcId": "vpc-a01106c2" } }
  • 如需 API 詳細資訊,請參閱《AWS CLI 命令參考》中的 AttachVpnGateway

PowerShell
Tools for PowerShell V4

範例 1:此範例會將指定的虛擬私有閘道,連接至指定的 VPC。

Add-EC2VpnGateway -VpnGatewayId vgw-1a2b3c4d -VpcId vpc-12345678

輸出:

State VpcId ----- ----- attaching vpc-12345678
  • 如需 API 詳細資訊,請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》中的 AttachVpnGateway

Tools for PowerShell V5

範例 1:此範例會將指定的虛擬私有閘道,連接至指定的 VPC。

Add-EC2VpnGateway -VpnGatewayId vgw-1a2b3c4d -VpcId vpc-12345678

輸出:

State VpcId ----- ----- attaching vpc-12345678
  • 如需 API 詳細資訊,請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》中的 AttachVpnGateway