CreateVpcPeeringConnection - Amazon GameLift
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

CreateVpcPeeringConnection

Establishes a VPC peering connection between a virtual private cloud (VPC) in an Amazon account with the VPC for your Amazon GameLift fleet. VPC peering enables the game servers on your fleet to communicate directly with other Amazon resources. You can peer with VPCs in any Amazon account that you have access to, including the account that you use to manage your Amazon GameLift fleets. You cannot peer with VPCs that are in different Regions. For more information, see VPC Peering with Amazon GameLift Fleets.

Before calling this operation to establish the peering connection, you first need to use CreateVpcPeeringAuthorization and identify the VPC you want to peer with. Once the authorization for the specified VPC is issued, you have 24 hours to establish the connection. These two operations handle all tasks necessary to peer the two VPCs, including acceptance, updating routing tables, etc.

To establish the connection, call this operation from the Amazon account that is used to manage the Amazon GameLift fleets. Identify the following values: (1) The ID of the fleet you want to be enable a VPC peering connection for; (2) The Amazon account with the VPC that you want to peer with; and (3) The ID of the VPC you want to peer with. This operation is asynchronous. If successful, a connection request is created. You can use continuous polling to track the request's status using DescribeVpcPeeringConnections , or by monitoring fleet events for success or failure using DescribeFleetEvents .

Related actions

All APIs by task

Request Syntax

{ "FleetId": "string", "PeerVpcAwsAccountId": "string", "PeerVpcId": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

Note

In the following list, the required parameters are described first.

FleetId

A unique identifier for the fleet. You can use either the fleet ID or ARN value. This tells Amazon GameLift which GameLift VPC to peer with.

Type: String

Pattern: ^fleet-\S+

Required: Yes

PeerVpcAwsAccountId

A unique identifier for the Amazon account with the VPC that you want to peer your Amazon GameLift fleet with. You can find your Account ID in the Amazon Web Services Management Console under account settings.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Required: Yes

PeerVpcId

A unique identifier for a VPC with resources to be accessed by your Amazon GameLift fleet. The VPC must be in the same Region as your fleet. To look up a VPC ID, use the VPC Dashboard in the Amazon Web Services Management Console. Learn more about VPC peering in VPC Peering with Amazon GameLift Fleets.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Required: Yes

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors.

InternalServiceException

The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.

HTTP Status Code: 500

InvalidRequestException

One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.

HTTP Status Code: 400

NotFoundException

The requested resources was not found. The resource was either not created yet or deleted.

HTTP Status Code: 400

UnauthorizedException

The client failed authentication. Clients should not retry such requests.

HTTP Status Code: 400

Examples

Peer the VPC for your Amazon GameLift fleet with a VPC on your Amazon GameLift account

This example builds on Example 1 in CreateVpcPeeringAuthorization. If authorization succeeded, the next step is to tell Amazon GameLift to request the peering connection. In this example, you want your game servers that are running on an Amazon GameLift fleet to be able to access a web service. The web service is managed through the same Amazon account that you use to manage your Amazon GameLift fleet. To request the peering, provide the following details for the two VPCs to peer: (1) the Amazon GameLift fleet ID, and (2) the account and VPC for the web service. The account ID and VPC for the web service must be the same one you used in the authorization.

The fleet's ID is fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa. The Amazon account (the same as the one you use to manage your Amazon GameLift fleet) is 111122223333. The VPC ID for the web service is vpc-a12bc345.

To make this request, sign in using your credentials for Amazon account 111122223333.

Sample Request

POST / HTTP/1.1 Host: gamelift.us-west-2.amazonaws.com; Accept-Encoding: identity Content-Length: 141 User-Agent: aws-cli/1.11.36 Python/2.7.9 Windows/7 botocore/1.4.93 Content-Type: application/x-amz-json-1.0 Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20170406/us-west-2/gamelift/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY X-Amz-Date: 20170406T004805Z X-Amz-Target: GameLift.CreateVpcPeeringConnection { "FleetId": "fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa", "PeerVpcAwsAccountId": "111122223333", "PeerVpcId": "vpc-a12bc345"}

Peer the VPC for your Amazon GameLift fleet with a VPC on a different account

This example builds on Example 2 in CreateVpcPeeringAuthorization. If authorization succeeded, the next step is to tell Amazon GameLift to request the peering connection. As in the previous example, you want your game servers that are running on an Amazon GameLift fleet to be able to access a web service. But in this example, the web service is managed by a different account from the one that you use to manage your Amazon GameLift fleet. To request the peering, provide the following details for the two VPCs to peer: (1) the Amazon GameLift fleet ID, and (2) the account and VPC for the web service. The account ID and VPC for the web service must be the same one you used in the authorization.

The fleet's ID is fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa. Your Amazon GameLift account ID is 111122223333. The Amazon account with the web service is 444455556666. The VPC ID for the web service is vpc-c67ef890.

To make this request, sign in using your credentials for Amazon account 111122223333 (your Amazon GameLift account).

Sample Request

POST / HTTP/1.1 Host: gamelift.us-west-2.amazonaws.com; Accept-Encoding: identity Content-Length: 141 User-Agent: aws-cli/1.11.36 Python/2.7.9 Windows/7 botocore/1.4.93 Content-Type: application/x-amz-json-1.0 Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20170406/us-west-2/gamelift/aws4_request, SignedHeaders=content-type;host;x-amz-date;x-amz-target, Signature=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY X-Amz-Date: 20170406T004805Z X-Amz-Target: GameLift.CreateVpcPeeringConnection { "FleetId": "fleet-2222bbbb-33cc-44dd-55ee-6666ffff77aa", "PeerVpcAwsAccountId": "444455556666", "PeerVpcId": "vpc-c67ef890"}

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: