AWS Fundamentals Logo
AWS Fundamentals
AWS::EC2::Subnet

EC2 Subnet

Specifies 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*.

Properties

17 configurable properties. 1 required. Click a row to see details.

Filter:
PropertyTypeFlags
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>

Return Values

Values returned after the resource is created. Access these with Fn::GetAtt.

AttributeTypeDescription
BlockPublicAccessStatesobject-
Ipv6CidrBlocksArray<string>-
NetworkAclAssociationIdstring-
SubnetIdstring-

Sample CloudFormation Template

A minimal template with required properties and common optional ones.

template.yaml
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: Production

Required IAM Permissions

Permissions CloudFormation needs in your IAM role to manage this resource.

create

ec2:DescribeSubnetsec2:CreateSubnetec2:CreateTagsec2:ModifySubnetAttribute

read

ec2:DescribeSubnetsec2:DescribeNetworkAcls

update

ec2:DescribeSubnetsec2:ModifySubnetAttributeec2:CreateTagsec2:DeleteTagsec2:AssociateSubnetCidrBlockec2:DisassociateSubnetCidrBlock

delete

ec2:DescribeSubnetsec2:DeleteSubnet

list

ec2:DescribeSubnetsec2:DescribeNetworkAcls

Get the EC2 Cheat Sheet

Everything you need to know about EC2 on one page. HD quality, print-friendly.

Download Free Infographic

Quick Facts

ServiceEC2
Properties21
Required1
TaggingSupported
Primary IDSubnetId

Supported Operations

CreateReadUpdateDeleteList

Immutable After Creation

These properties cannot be changed after the resource is created. Updating them triggers a replacement.

VpcIdAvailabilityZoneAvailabilityZoneIdCidrBlockOutpostArnIpv6NativeIpv4IpamPoolIdIpv4NetmaskLengthIpv6IpamPoolIdIpv6NetmaskLength

External Links