将 AttachVpnGateway 与 CLI 配合使用
以下代码示例演示如何使用 AttachVpnGateway。
- CLI
-
- AWS CLI
-
将虚拟专用网关连接到 VPC
以下
attach-vpn-gateway示例将指定的虚拟专用网关连接到指定的 VPC。aws ec2 attach-vpn-gateway \ --vpn-gateway-idvgw-9a4cacf3\ --vpc-idvpc-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。
-
有关 AWS SDK 开发人员指南和代码示例的完整列表,请参阅 使用 AWS SDK 创建 Amazon EC2 资源。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。
AttachVolume
AuthorizeSecurityGroupEgress