Thanks for letting us know we're doing a good job!
If you've got a moment, please tell us what we did right so we can do more of it.
Specifies a subnet for a VPC.
When you create each subnet, you provide the VPC ID and IPv4 CIDR block for the subnet. After you create a subnet, you can't change its CIDR block. The size of the subnet's IPv4 CIDR block can be the same as a VPC's IPv4 CIDR block, or a subset of a VPC's IPv4 CIDR block. If you create more than one subnet in a VPC, the subnets' CIDR blocks must not overlap. The smallest IPv4 subnet (and VPC) you can create uses a /28 netmask (16 IPv4 addresses), and the largest uses a /16 netmask (65,536 IPv4 addresses).
If you've associated an IPv6 CIDR block with your VPC, you can create a subnet with an IPv6 CIDR block that uses a /64 prefix length.
To declare this entity in your AWS CloudFormation template, use the following syntax:
{ "Type" : "AWS::EC2::Subnet", "Properties" : { "AssignIpv6AddressOnCreation" :Boolean, "AvailabilityZone" :String, "CidrBlock" :String, "Ipv6CidrBlock" :String, "MapPublicIpOnLaunch" :Boolean, "Tags" :[ Tag, ... ], "VpcId" :String} }
Type: AWS::EC2::Subnet Properties: AssignIpv6AddressOnCreation:BooleanAvailabilityZone:StringCidrBlock:StringIpv6CidrBlock:StringMapPublicIpOnLaunch:BooleanTags:- TagVpcId:String
AssignIpv6AddressOnCreationIndicates whether a network interface created in this subnet receives an IPv6 address.
The default value is false.
If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock.
If you specify AssignIpv6AddressOnCreation, you cannot specify MapPublicIpOnLaunch.
Required: No
Type: Boolean
Update requires: No interruption
AvailabilityZoneThe Availability Zone of the subnet.
If you update this property, you must also update the CidrBlock property.
Required: No
Type: String
Update requires: Replacement
CidrBlockThe IPv4 CIDR block assigned to the subnet.
If you update this property, you must also update the AvailabilityZone property.
Required: Yes
Type: String
Update requires: Replacement
Ipv6CidrBlockThe IPv6 CIDR block.
If you specify AssignIpv6AddressOnCreation, you must also specify Ipv6CidrBlock.
Required: Conditional
Type: String
Update requires: No interruption
MapPublicIpOnLaunchIndicates whether instances launched in this subnet receive a public IPv4 address.
If you specify MapPublicIpOnLaunch, you cannot specify AssignIpv6AddressOnCreation.
Required: No
Type: Boolean
Update requires: No interruption
TagsAny tags assigned to the subnet.
Required: No
Type: List of Tag
Update requires: No interruption
VpcIdThe ID of the VPC the subnet is in.
If you update this property, you must also update the CidrBlock property.
Required: Yes
Type: String
Update requires: Replacement
When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the ID of the subnet.
For more information about using the Ref function, see Ref.
The Fn::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 the Fn::GetAtt intrinsic function, see Fn::GetAtt.
AvailabilityZoneThe Availability Zone of this subnet. For example:
{ "Fn::GetAtt" : [ "mySubnet", "AvailabilityZone" ] }
Ipv6CidrBlocksThe IPv6 CIDR blocks that are associated with the subnet, such as [ 2001:db8:1234:1a00::/64 ].
NetworkAclAssociationIdThe ID of the network ACL that is associated with the subnet's VPC, such as
acl-5fb85d36.
VpcIdThe ID of the subnet's VPC, such as vpc-11ad4878.
The following example uses the VPC ID from a VPC named myVPC that was declared elsewhere in the same template.
"mySubnet" : { "Type" : "AWS::EC2::Subnet", "Properties" : { "VpcId" : { "Ref" : "myVPC" }, "CidrBlock" : "10.0.0.0/24", "AvailabilityZone" : "us-east-1a", "Tags" : [ { "Key" : "foo", "Value" : "bar" } ] } }
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 EC2 API Reference
Your VPC and Subnets in the Amazon Virtual Private Cloud User Guide