| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
Creates a subnet in an existing VPC.
{
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"AvailabilityZone" : String,
"CidrBlock" : String,
"Tags" : [ EC2 Tag, ... ],
"VpcId" : { "Ref" : String }
}
} The availability zone in which you want the subnet. Default: AWS selects a zone for you (recommended).
Required: No
Type: String
Update requires: replacement. Modifying this property requires that the CIDR block be changed.
The CIDR block that you want the subnet to cover (for example,
"10.0.0.0/24").
Required: Yes
Type: String
Update requires: replacement
The tags that you want to attach to this resource.
Required: No
Type: A list of EC2 Tags.
Update requires: no interruption
A Ref structure that contains the ID of the VPC on which you want to create the
subnet. The VPC ID is provided as the value of the "Ref" property, as: {
"Ref": "VPCID" }.
Required: Yes
Type: Ref ID
Update requires: replacement. Modifying this property requires that the CIDR block be changed.
You can pass the logical ID of the resource to an intrinsic function to get a value back from the resource. The value that is returned depends on the function used.
When the logical ID of this resource is provided to the Ref intrinsic
function, it returns the resource name.
For more information about using the Ref function, see Ref.
Fn::GetAtt returns a value for a specified attribute of this type.
This section lists the available attributes and corresponding return values.
Returns the availability zone (for example, "us-east-1a") of
this subnet.
Example:
{ "Fn::GetAtt" : [ "mySubnet", "AvailabilityZone" ] } For more information about using Fn:GetAtt, see Fn::GetAtt.
The following example snippet uses the VPC ID from a VPC named myVPC that was declared elsewhere in the same template.
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Resources" : {
"mySubnet" : {
"Type" : "AWS::EC2::Subnet",
"Properties" : {
"VpcId" : { "Ref" : "myVPC" },
"CidrBlock" : "10.0.0.0/24",
"AvailabilityZone" : "us-east-1a",
"Tags" : [ { "Key" : "foo", "Value" : "bar" } ]
}
}
}
} CreateSubnet in the Amazon Elastic Compute Cloud API Reference
Using Tags in the Amazon Elastic Compute Cloud User Guide