There are more AWS SDK examples available in the AWS Doc SDK Examples
Use CreateVpnGateway with a CLI
The following code examples show how to use CreateVpnGateway.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code example:
- CLI
-
- AWS CLI
-
Example 1: To create a virtual private gateway
The following
create-vpn-gatewayexample creates a virtual private gateway.aws ec2 create-vpn-gateway \ --typeipsec.1Output:
{ "VpnGateway": { "AmazonSideAsn": 64512, "State": "available", "Type": "ipsec.1", "VpnGatewayId": "vgw-9a4cacf3", "VpcAttachments": [] } }For more information, see How AWS Site-to-Site VPN works in the AWS Site-to-Site VPN User Guide.
Example 2: To create a virtual private gateway with a specific Amazon-side ASN
The following
create-vpn-gatewayexample creates a virtual private gateway and specifies the Autonomous System Number (ASN) for the Amazon side of the BGP session.aws ec2 create-vpn-gateway \ --typeipsec.1\ --amazon-side-asn65001Output:
{ "VpnGateway": { "AmazonSideAsn": 65001, "State": "available", "Type": "ipsec.1", "VpnGatewayId": "vgw-9a4cacf3", "VpcAttachments": [] } }For more information, see How AWS Site-to-Site VPN works in the AWS Site-to-Site VPN User Guide.
-
For API details, see CreateVpnGateway
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: This example creates the specified virtual private gateway.
New-EC2VpnGateway -Type ipsec.1Output:
AvailabilityZone : State : available Tags : {} Type : ipsec.1 VpcAttachments : {} VpnGatewayId : vgw-1a2b3c4d-
For API details, see CreateVpnGateway in AWS Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: This example creates the specified virtual private gateway.
New-EC2VpnGateway -Type ipsec.1Output:
AvailabilityZone : State : available Tags : {} Type : ipsec.1 VpcAttachments : {} VpnGatewayId : vgw-1a2b3c4d-
For API details, see CreateVpnGateway in AWS Tools for PowerShell Cmdlet Reference (V5).
-