AWS::EC2::SubnetSpecifies a subnet for the specified VPC. For an IPv4 only subnet, specify an IPv4 CIDR block. If the VPC has an IPv6 CIDR block, you can create an IPv6 only subnet or a dual stack subnet instead. For an IPv6 only subnet, specify an IPv6 CIDR block. For a dual stack subnet, specify both an IPv4 CIDR block and an IPv6 CIDR block. For more information, see [Subnets for your VPC](https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html) in the *Amazon VPC User Guide*.
17 configurable properties. 1 required. Click a row to see details.
| Property | Type | Flags |
|---|---|---|
VpcId | string | RequiredCreate-only |
AssignIpv6AddressOnCreation | boolean | |
AvailabilityZone | string | Create-only |
AvailabilityZoneId | string | Create-only |
CidrBlock | string | Create-only |
EnableDns64 | boolean | |
EnableLniAtDeviceIndex | integer | Write-only |
Ipv4IpamPoolId | string | Create-onlyWrite-only |
Ipv4NetmaskLength | integer | Create-onlyWrite-only |
Ipv6CidrBlock | string | |
Ipv6IpamPoolId | string | Create-onlyWrite-only |
Ipv6Native | boolean | Create-only |
Ipv6NetmaskLength | integer | Create-onlyWrite-only |
MapPublicIpOnLaunch | boolean | |
OutpostArn | string | Create-only |
PrivateDnsNameOptionsOnLaunch | object | |
Tags | Array<Tag> |
Values returned after the resource is created. Access these with Fn::GetAtt.
| Attribute | Type | Description |
|---|---|---|
BlockPublicAccessStates | object | - |
Ipv6CidrBlocks | Array<string> | - |
NetworkAclAssociationId | string | - |
SubnetId | string | - |
A minimal template with required properties and common optional ones.
AWSTemplateFormatVersion: "2010-09-09"
Description: Sample template for AWS::EC2::Subnet
Resources:
MyResource:
Type: AWS::EC2::Subnet
Properties:
VpcId: "my-vpcid"
Tags:
- Key: Environment
Value: ProductionPermissions CloudFormation needs in your IAM role to manage this resource.
ec2:DescribeSubnetsec2:CreateSubnetec2:CreateTagsec2:ModifySubnetAttributeec2:DescribeSubnetsec2:DescribeNetworkAclsec2:DescribeSubnetsec2:ModifySubnetAttributeec2:CreateTagsec2:DeleteTagsec2:AssociateSubnetCidrBlockec2:DisassociateSubnetCidrBlockec2:DescribeSubnetsec2:DeleteSubnetec2:DescribeSubnetsec2:DescribeNetworkAclsEverything you need to know about EC2 on one page. HD quality, print-friendly.
Download Free InfographicSubnetIdThese properties cannot be changed after the resource is created. Updating them triggers a replacement.
VpcIdAvailabilityZoneAvailabilityZoneIdCidrBlockOutpostArnIpv6NativeIpv4IpamPoolIdIpv4NetmaskLengthIpv6IpamPoolIdIpv6NetmaskLength