Menu
AWS CloudFormation
User Guide (API Version 2010-05-15)

AWS::EC2::VPCCidrBlock

The AWS::EC2::VPCCidrBlock resource associates a single Amazon-provided IPv6 CIDR block or a single user-specified IPv4 CIDR block with a Virtual Private Cloud (VPC).

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::EC2::VPCCidrBlock", "Properties" : { "AmazonProvidedIpv6CidrBlock" : Boolean, "CidrBlock" : String, "VpcId" : String } }

YAML

Type: "AWS::EC2::VPCCidrBlock" Properties: AmazonProvidedIpv6CidrBlock: Boolean CidrBlock: String VpcId: String

Properties

AmazonProvidedIpv6CidrBlock

Whether to request an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC. You can't specify the range of IPv6 addresses or the size of the CIDR block.

Required: No

Type: Boolean

Update requires: Replacement

CidrBlock

An IPv4 CIDR block to associate with the VPC.

Required: No

Type: String

Update requires: Replacement

VpcId

The ID of the VPC to associate the Amazon-provided IPv6 CIDR block with.

Required: Yes

Type: String

Update requires: Replacement

Examples

Associate an Amazon-provided IPv6 CIDR block

The following snippet associates an Amazon-provided IPv6 CIDR block (with a prefix length of /56) with the TestVPCIpv6 VPC.

JSON

{ "Ipv6VPCCidrBlock": { "Type": "AWS::EC2::VPCCidrBlock", "Properties": { "AmazonProvidedIpv6CidrBlock": true, "VpcId": { "Ref" : "TestVPCIpv6" } } } }

YAML

Ipv6VPCCidrBlock: Type: "AWS::EC2::VPCCidrBlock" Properties: AmazonProvidedIpv6CidrBlock: true VpcId: !Ref TestVPCIpv6

Associate an IPv4 CIDR block and Amazon-provided IPv6 CIDR block

The following example associates an IPv4 CIDR block and an Amazon-provided IPv6 CIDR block with a VPC. It also outputs the list of IPv4 CIDR block association IDs and IPv6 CIDR blocks that are associated with the VPC.

JSON

{ "Resources": { "VPC": { "Type": "AWS::EC2::VPC", "Properties": { "CidrBlock": "10.0.0.0/24" } }, "VpcCidrBlock": { "Type": "AWS::EC2::VPCCidrBlock", "Properties": { "VpcId": { "Ref": "VPC" }, "CidrBlock": "192.0.0.0/24" } }, "VpcCidrBlockIpv6": { "Type": "AWS::EC2::VPCCidrBlock", "Properties": { "VpcId": { "Ref": "VPC" }, "AmazonProvidedIpv6CidrBlock": true } } }, "Outputs": { "VpcId": { "Value": { "Ref": "VPC" } }, "PrimaryCidrBlock": { "Value": { "Fn::GetAtt": [ "VPC", "CidrBlock" ] } }, "Ipv6CidrBlock": { "Value": { "Fn::Select": [ 0, { "Fn::GetAtt": [ "VPC", "Ipv6CidrBlocks" ] } ] } }, "CidrBlockAssociation": { "Value": { "Fn::Select": [ 0, { "Fn::GetAtt": [ "VPC", "CidrBlockAssociations" ] } ] } } } }

YAML

Resources: VPC: Type: "AWS::EC2::VPC" Properties: CidrBlock: 10.0.0.0/24 VpcCidrBlock: Type: "AWS::EC2::VPCCidrBlock" Properties: VpcId: !Ref VPC CidrBlock: 192.0.0.0/24 VpcCidrBlockIpv6: Type: "AWS::EC2::VPCCidrBlock" Properties: VpcId: !Ref VPC AmazonProvidedIpv6CidrBlock: true Outputs: VpcId: Value: !Ref VPC PrimaryCidrBlock: Value: !GetAtt VPC.CidrBlock Ipv6CidrBlock: Value: !Select [ 0, !GetAtt VPC.Ipv6CidrBlocks ] CidrBlockAssociation: Value: !Select [ 0, !GetAtt VPC.CidrBlockAssociations ]

On this page: