Menu
Amazon GameLift Service
API Reference (API Version 2015-10-01)

CreateVpcPeeringConnection

Establishes a VPC peering connection between a virtual private cloud (VPC) in an AWS account with the VPC for your Amazon GameLift fleet. VPC peering enables the game servers on your fleet to communicate directly with other AWS resources. You can peer with VPCs in any AWS 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 call 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 AWS 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 AWS 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 VpcPeeringConnection 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.

VPC peering connection operations include:

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

Unique identifier for a fleet. This tells Amazon GameLift which GameLift VPC to peer with.

Type: String

Pattern: ^fleet-\S+

Required: Yes

PeerVpcAwsAccountId

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

Type: String

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

Required: Yes

PeerVpcId

Unique identifier for a VPC with resources to be accessed by your Amazon GameLift fleet. The VPC must be in the same region where your fleet is deployed. To get VPC information, including IDs, use the Virtual Private Cloud service tools, including the VPC Dashboard in the AWS Management Console.

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

A service resource associated with the request could not be found. Clients should not retry such requests.

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 AWS 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 AWS 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-abcd678e-fab9-0c1d-2345-e6f789abc01d. The AWS 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 AWS account 111122223333. To view the resulting new connection record, call DescribeVpcPeeringConnections with the fleet ID.

HTTP requests are authenticated using an AWS Signature Version 4 signature in the Authorization header field.

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-abcd678e-fab9-0c1d-2345-e6f789abc01d",
    "PeerVpcAwsAccountId": "111122223333",
    "PeerVpcId": "vpc-a12bc345"}

Peer the VPC for your Amazon GameLift fleet with a VPC on a different AWS 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-abcd678e-fab9-0c1d-2345-e6f789abc01d. Your Amazon GameLift account ID is 111122223333. The AWS 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 AWS account 111122223333 (your Amazon GameLift account). To view resulting new connection record, call DescribeVpcPeeringConnections with the fleet ID.

HTTP requests are authenticated using an AWS Signature Version 4 signature in the Authorization header field.

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-abcd678e-fab9-0c1d-2345-e6f789abc01d",
    "PeerVpcAwsAccountId": "444455556666",
    "PeerVpcId": "vpc-c67ef890"}

See Also

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