Attaching a Virtual Private Gateway

You can attach a virtual private gateway to a Virtual Private Cloud (VPC). You can then set up a VPN connection between the VPC and a customer gateway. For more information, see Tutorial: Setting up a VPN Connection.

This action updates the attachment state of the virtual private gateway from detached to attached, while the virtual private gateway remains in the available state. For more information, see About Virtual Private Gateways > Lifecycle.

You can attach each virtual private gateway to one VPC only at a time. You can attach a virtual private gateway to a VPC before or after creating the VPN connection. For more information, see Creating a VPN Connection.

Attaching a Virtual Private Gateway Using Cockpit

Before you begin:

  1. Click VPC > Virtual Private Gateways.

  2. Select the virtual private gateway you want to attach.
    The virtual private gateway is selected.

  3. Click Attach .
    The ATTACH VGW-XXXXXXXX dialog box appears.

  4. In the VPC list, select the ID of the VPC to which you want to attach the virtual private gateway.

  5. Click Attach to validate
    The virtual private gateway is attached to the specified VPC.

Attaching a Virtual Private Gateway Using AWS CLI

Before you begin:

To attach a virtual private gateway to a VPC, use the attach-vpn-gateway command following this syntax:

Request sample
$ aws ec2 attach-vpn-gateway \
    --profile YOU_PROFILE \
    --vpn-gateway-id vgw-00ac2c82 \
    --vpc-id vpc-eb1e7306 \
    --endpoint https://fcu.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • vpn-gateway-id: The ID of the virtual private gateway you want to attach.

  • vpc-id: The ID of the VPC you want to attach the virtual private gateway to.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The attach-vpn-gateway command returns the following elements:

  • State: The state of the attachment (attaching | attached | detaching | detached). For more information, see About Virtual Private Gateways.

  • VpcId: The ID of the VPC to which the virtual private gateway is attached.

Result sample
 {
    "VpcAttachment": {
        "State": "attached",
        "VpcId": "vpc-eb1e7306"
    }
}

The virtual private gateway is attached to the specified VPC.

Related Pages

Corresponding API Method

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.