This is the newCloudFormation Template Reference Guide. Please update your bookmarks and links. For help getting started with CloudFormation, see theAWS CloudFormation User Guide.
Specifies a virtual private cloud (VPC).
A VPC must have an associated IPv4 CIDR block. You can specify an IPv4 CIDR block or an IPAM-allocated IPv4 CIDR block. To associate an IPv6 CIDR block with the VPC, seeAWS::EC2::VPCCidrBlock.
For more information, seeVirtual private clouds (VPC) in theAmazon VPC User Guide.
To declare this entity in your CloudFormation template, use the following syntax:
{ "Type" : "AWS::EC2::VPC", "Properties" :{ "CidrBlock" :String, "EnableDnsHostnames" :Boolean, "EnableDnsSupport" :Boolean, "InstanceTenancy" :String, "Ipv4IpamPoolId" :String, "Ipv4NetmaskLength" :Integer, "Tags" :[Tag, ... ] }}Type: AWS::EC2::VPCProperties:CidrBlock:StringEnableDnsHostnames:BooleanEnableDnsSupport:BooleanInstanceTenancy:StringIpv4IpamPoolId:StringIpv4NetmaskLength:IntegerTags: -TagCidrBlockThe IPv4 network range for the VPC, in CIDR notation. For example,10.0.0.0/16. We modify the specified CIDR block to its canonical form; for example, if you specify100.68.0.18/18, we modify it to100.68.0.0/18.
You must specify eitherCidrBlock orIpv4IpamPoolId.
Required: Conditional
Type: String
Update requires:Replacement
EnableDnsHostnamesIndicates whether the instances launched in the VPC get DNS hostnames. If enabled, instances in the VPC get DNS hostnames; otherwise, they do not. Disabled by default for nondefault VPCs. For more information, seeDNS attributes in your VPC.
You can only enable DNS hostnames if you've enabled DNS support.
Required: No
Type: Boolean
Update requires:No interruption
EnableDnsSupportIndicates whether the DNS resolution is supported for the VPC. If enabled, queries to the Amazon provided DNS server at the 169.254.169.253 IP address, or the reserved IP address at the base of the VPC network range "plus two" succeed. If disabled, the Amazon provided DNS service in the VPC that resolves public DNS hostnames to IP addresses is not enabled. Enabled by default. For more information, seeDNS attributes in your VPC.
Required: No
Type: Boolean
Update requires:No interruption
InstanceTenancyThe allowed tenancy of instances launched into the VPC.
default: An instance launched into the VPC runs on shared hardware by default, unless you explicitly specify a different tenancy during instance launch.
dedicated: An instance launched into the VPC runs on dedicated hardware by default, unless you explicitly specify a tenancy ofhost during instance launch. You cannot specify a tenancy ofdefault during instance launch.
UpdatingInstanceTenancy requires no replacement only if you are updating its value fromdedicated todefault. UpdatingInstanceTenancy fromdefault todedicated requires replacement.
Required: No
Type: String
Allowed values:default | dedicated | host
Update requires:Some interruptions
Ipv4IpamPoolIdThe ID of an IPv4 IPAM pool you want to use for allocating this VPC's CIDR. For more information, seeWhat is IPAM? in theAmazon VPC IPAM User Guide.
You must specify eitherCidrBlock orIpv4IpamPoolId.
Required: Conditional
Type: String
Update requires:Replacement
Ipv4NetmaskLengthThe netmask length of the IPv4 CIDR you want to allocate to this VPC from an Amazon VPC IP Address Manager (IPAM) pool. For more information about IPAM, seeWhat is IPAM? in theAmazon VPC IPAM User Guide.
Required: No
Type: Integer
Update requires:Replacement
TagsThe tags for the VPC.
Required: No
Type: Array ofTag
Update requires:No interruption
When you pass the logical ID of this resource to the intrinsicRef function,Ref returns the ID of the VPC.
For more information about using theRef function, seeRef.
TheFn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.
For more information about using theFn::GetAtt intrinsic function, seeFn::GetAtt.
CidrBlockThe primary IPv4 CIDR block for the VPC. For example, 10.0.0.0/16.
CidrBlockAssociationsThe association IDs of the IPv4 CIDR blocks for the VPC. For example, [ vpc-cidr-assoc-0280ab6b ].
DefaultNetworkAclThe ID of the default network ACL for the VPC. For example, acl-814dafe3.
DefaultSecurityGroupThe ID of the default security group for the VPC. For example, sg-b178e0d3.
Ipv6CidrBlocksThe IPv6 CIDR blocks for the VPC. For example, [ 2001:db8:1234:1a00::/56 ].
VpcIdThe ID of the VPC.
The following example specifies a VPC with an IPv4 address.
{ "Resources":{ "myVPC" :{ "Type" : "AWS::EC2::VPC", "Properties" :{ "CidrBlock" : "10.0.0.0/16", "EnableDnsSupport" : "true", "EnableDnsHostnames" : "true", "Tags" : [{"Key" : "stack", "Value" : "production"} ] } } }}Resources: myVPC: Type: AWS::EC2::VPC Properties: CidrBlock: 10.0.0.0/16 EnableDnsSupport: 'true' EnableDnsHostnames: 'true' Tags: - Key: stack Value: productionThe following example specifies a VPC with an IPv4 address range and an IPv6 address range.
{ "Resources":{ "myVPC" :{ "Type" : "AWS::EC2::VPC", "Properties" :{ "CidrBlock" : "10.0.0.0/16", "EnableDnsSupport" : "true", "EnableDnsHostnames" : "true", "Tags" : [{"Key" : "stack", "Value" : "production"} ] } }, "ipv6CidrBlock":{ "Type": "AWS::EC2::VPCCidrBlock", "Properties":{ "VpcId":{ "Ref": "myVPC" }, "AmazonProvidedIpv6CidrBlock": true } } }}Resources: myVPC: Type: AWS::EC2::VPC Properties: CidrBlock: 10.0.0.0/16 EnableDnsSupport: 'true' EnableDnsHostnames: 'true' Tags: - Key: stack Value: production ipv6CidrBlock: Type: AWS::EC2::VPCCidrBlock Properties: VpcId: !Ref myVPC AmazonProvidedIpv6CidrBlock: trueCreateVpc in theAmazon EC2 API Reference
VPC and subnets in theAmazon VPC User Guide