AWS::EC2::VPC
Creates a Virtual Private Cloud (VPC) with the CIDR block that you specify. To name
a VPC resource, use the Tags property and specify a value for the Name key.
Syntax
To declare this entity in your AWS CloudFormation template, use the following syntax:
JSON
{ "Type" : "AWS::EC2::VPC", "Properties" : { "CidrBlock" :String, "EnableDnsSupport" :Boolean, "EnableDnsHostnames" :Boolean, "InstanceTenancy" :String, "Tags" : [Resource Tag, ...] } }
YAML
Type: AWS::EC2::VPC Properties: CidrBlock:StringEnableDnsSupport:BooleanEnableDnsHostnames:BooleanInstanceTenancy:StringTags: -Resource Tag
Properties
CidrBlock-
The CIDR block you want the VPC to cover. For example:
"10.0.0.0/16".Required: Yes
Type: String
Update requires: Replacement
EnableDnsSupport-
Specifies whether DNS resolution is supported for the VPC. If this attribute is
true, the Amazon DNS server resolves DNS hostnames for your instances to their corresponding IP addresses; otherwise, it does not. By default the value is set totrue.Required: No
Type: Boolean
Update requires: No interruption
EnableDnsHostnames-
Specifies whether the instances launched in the VPC get DNS hostnames. If this attribute is
true, instances in the VPC get DNS hostnames; otherwise, they do not. You can only setEnableDnsHostnamestotrueif you also set theEnableDnsSupportattribute totrue. By default, the value is set tofalse.Required: No
Type: Boolean
Update requires: No interruption
InstanceTenancy-
The allowed tenancy of instances launched into the VPC.
-
"default": Instances can be launched with any tenancy. -
"dedicated": Any instance launched into the VPC automatically has dedicated tenancy, unless you launch it with the default tenancy.
Update: Conditional. Updating
InstanceTenancyrequires no replacement only if you are updating its value from"dedicated"to"default". UpdatingInstanceTenancyfrom"default"to"dedicated"requires replacement.Required: No
Type: String
Valid values:
"default"or"dedicated"Update requires: No interruption
-
Tags-
An arbitrary set of tags (key–value pairs) for this VPC. To name a VPC resource, specify a value for the
Namekey.Required: No
Type: Resource Tag
Update requires: No interruption.
Return Values
Ref
When the logical ID of this resource is provided to the Ref
intrinsic function, Ref returns the resource ID, such as
vpc-18ac277d.
For more information about using the Ref function, see Ref.
Fn::GetAtt
Fn::GetAtt returns a value for a specified attribute of this type.
The following are the available attributes and sample return values.
CidrBlock-
The set of IP addresses for the VPC. For example,
10.0.0.0/16. CidrBlockAssociations-
A list of IPv4 CIDR block association IDs for the VPC. For example,
[ vpc-cidr-assoc-0280ab6b ]. DefaultNetworkAcl-
The default network ACL ID that is associated with the VPC. For example,
acl-814dafe3. DefaultSecurityGroup-
The default security group ID that is associated with the VPC. For example,
sg-b178e0d3. Ipv6CidrBlocks-
A list of IPv6 CIDR blocks that are associated with the VPC, such as
[ 2001:db8:1234:1a00::/56 ].
For more information about using Fn::GetAtt, see Fn::GetAtt.
Example
JSON
{ "AWSTemplateFormatVersion" : "2010-09-09", "Resources" : { "myVPC" : { "Type" : "AWS::EC2::VPC", "Properties" : { "CidrBlock" : "10.0.0.0/16", "EnableDnsSupport" : "false", "EnableDnsHostnames" : "false", "InstanceTenancy" : "dedicated", "Tags" : [ {"Key" : "foo", "Value" : "bar"} ] } } } }
YAML
AWSTemplateFormatVersion: '2010-09-09' Resources: myVPC: Type: AWS::EC2::VPC Properties: CidrBlock: 10.0.0.0/16 EnableDnsSupport: 'false' EnableDnsHostnames: 'false' InstanceTenancy: dedicated Tags: - Key: foo Value: bar
More Info
-
CreateVpc in the Amazon EC2 API Reference.
