Menu
Amazon Elastic Compute Cloud
API Reference (API Version 2016-11-15)

AssociateVpcCidrBlock

Associates a CIDR block with your VPC. You can associate a secondary IPv4 CIDR block, or you can associate an Amazon-provided IPv6 CIDR block. The IPv6 CIDR block size is fixed at /56.

For more information about associating CIDR blocks with your VPC and applicable restrictions, see VPC and Subnet Sizing in the Amazon Virtual Private Cloud User Guide.

Request Parameters

The following parameters are for this specific action. For more information about required and optional parameters that are common to all actions, see Common Query Parameters.

AmazonProvidedIpv6CidrBlock

Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC. You cannot specify the range of IPv6 addresses, or the size of the CIDR block.

Type: Boolean

Required: No

CidrBlock

An IPv4 CIDR block to associate with the VPC.

Type: String

Required: No

VpcId

The ID of the VPC.

Type: String

Required: Yes

Response Elements

The following elements are returned by the service.

cidrBlockAssociation

Information about the IPv4 CIDR block association.

Type: VpcCidrBlockAssociation object

ipv6CidrBlockAssociation

Information about the IPv6 CIDR block association.

Type: VpcIpv6CidrBlockAssociation object

requestId

The ID of the request.

Type: String

vpcId

The ID of the VPC.

Type: String

Errors

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

Examples

Example 1

This example associates an IPv6 CIDR block with VPC vpc-1a2b3c4d.

Sample Request

https://ec2.amazonaws.com/?Action=AssociateVpcCidrBlock &VpcId=vpc-1a2b3c4d &AmazonProvidedIpv6CidrBlock=true &AUTHPARAMS

Sample Response

<AssociateVpcCidrBlock xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <ipv6CidrBlockAssociation> <ipv6CidrBlockState> <state>associating</state> </ipv6CidrBlockState> <associationId>vpc-cidr-assoc-e2a5408b</associationId> </ipv6CidrBlockAssociation> <vpcId>vpc-1a2b3c4d</vpcId> </AssociateVpcCidrBlock>

Example 2

This example associates the IPv4 CIDR block 10.2.0.0/16 with VPC vpc-1a2b3c4d.

Sample Request

https://ec2.amazonaws.com/?Action=AssociateVpcCidrBlock &VpcId=vpc-1a2b3c4d &CidrBlock=10.2.0.0/16 &AUTHPARAMS

Sample Response

<AssociateVpcCidrBlockResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/"> <requestId>33af6c54-1139-4d50-b4f7-15a8example</requestId> <vpcId>vpc-1a2b3c4d</vpcId> <cidrBlockAssociation> <associationId>vpc-cidr-assoc-0280ab6b</associationId> <cidrBlock>10.2.0.0/16</cidrBlock> <cidrBlockState> <state>associating</state> </cidrBlockState> </cidrBlockAssociation> </AssociateVpcCidrBlockResponse>

See Also

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