AWS::EC2::VPCCidrBlock
Associates a CIDR block with your VPC.
You can optionally request an IPv6 CIDR block for the VPC. You can request an Amazon-provided IPv6 CIDR block from Amazon's pool of IPv6 addresses, or an IPv6 CIDR block from an IPv6 address pool that you provisioned through bring your own IP addresses (BYOIP).
For more information, see VPC CIDR blocks in the Amazon VPC User Guide.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::EC2::VPCCidrBlock", "Properties" : { "AmazonProvidedIpv6CidrBlock" :
Boolean
, "CidrBlock" :String
, "Ipv4IpamPoolId" :String
, "Ipv4NetmaskLength" :Integer
, "Ipv6CidrBlock" :String
, "Ipv6IpamPoolId" :String
, "Ipv6NetmaskLength" :Integer
, "Ipv6Pool" :String
, "VpcId" :String
} }
YAML
Type: AWS::EC2::VPCCidrBlock Properties: AmazonProvidedIpv6CidrBlock:
Boolean
CidrBlock:String
Ipv4IpamPoolId:String
Ipv4NetmaskLength:Integer
Ipv6CidrBlock:String
Ipv6IpamPoolId:String
Ipv6NetmaskLength:Integer
Ipv6Pool:String
VpcId:String
Properties
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.
Required: No
Type: Boolean
Update requires: Replacement
CidrBlock
-
An IPv4 CIDR block to associate with the VPC.
Required: No
Type: String
Update requires: Replacement
Ipv4IpamPoolId
-
Associate a CIDR allocated from an IPv4 IPAM pool to a VPC. For more information about Amazon VPC IP Address Manager (IPAM), see What is IPAM? in the Amazon VPC IPAM User Guide.
Required: No
Type: String
Update requires: Replacement
Ipv4NetmaskLength
-
The netmask length of the IPv4 CIDR you would like to associate from an Amazon VPC IP Address Manager (IPAM) pool. For more information about IPAM, see What is IPAM? in the Amazon VPC IPAM User Guide.
Required: No
Type: Integer
Update requires: Replacement
Ipv6CidrBlock
-
An IPv6 CIDR block from the IPv6 address pool. You must also specify
Ipv6Pool
in the request.To let Amazon choose the IPv6 CIDR block for you, omit this parameter.
Required: No
Type: String
Update requires: Replacement
Ipv6IpamPoolId
-
Associates a CIDR allocated from an IPv6 IPAM pool to a VPC. For more information about Amazon VPC IP Address Manager (IPAM), see What is IPAM? in the Amazon VPC IPAM User Guide.
Required: No
Type: String
Update requires: Replacement
Ipv6NetmaskLength
-
The netmask length of the IPv6 CIDR you would like to associate from an Amazon VPC IP Address Manager (IPAM) pool. For more information about IPAM, see What is IPAM? in the Amazon VPC IPAM User Guide.
Required: No
Type: Integer
Update requires: Replacement
Ipv6Pool
-
The ID of an IPv6 address pool from which to allocate the IPv6 CIDR block.
Required: No
Type: String
Update requires: Replacement
VpcId
-
The ID of the VPC.
Required: Yes
Type: String
Update requires: Replacement
Return values
Ref
When you pass the logical ID of this resource to the intrinsic Ref
function, Ref
returns the association ID for the VPC CIDR block.
For more information about using the Ref
function, see Ref
.
Fn::GetAtt
IpSource
-
The source that allocated the IP address space.
byoip
oramazon
indicates public IP address space allocated by Amazon or space that you have allocated with Bring your own IP (BYOIP).none
indicates private space. Ipv6AddressAttribute
-
Public IPv6 addresses are those advertised on the internet from AWS. Private IP addresses are not and cannot be advertised on the internet from AWS.
Examples
Associate an Amazon-provided IPv6 CIDR block
The following example 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 an 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 ]