Carina

Resource

awscc.ec2.Subnet

CloudFormation Type: AWS::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 in the Amazon VPC User Guide.

Example

let vpc = awscc.ec2.Vpc {
  cidr_block           = '10.0.0.0/16'
  enable_dns_support   = true
  enable_dns_hostnames = true
}

awscc.ec2.Subnet {
  vpc_id                  = vpc.vpc_id
  cidr_block              = '10.0.1.0/24'
  availability_zone       = 'ap-northeast-1a'
  map_public_ip_on_launch = true

  tags = {
    Environment = 'example'
  }
}

Argument Reference

assign_ipv6_address_on_creation

Indicates 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 an IPv6 CIDR block.

availability_zone

The Availability Zone of the subnet. If you update this property, you must also update the CidrBlock property.

availability_zone_id

The AZ ID of the subnet.

cidr_block

The IPv4 CIDR block assigned to the subnet. If you update this property, we create a new subnet, and then delete the existing one.

enable_dns64

Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations. You must first configure a NAT gateway in a public subnet (separate from the subnet containing the IPv6-only workloads). For example, the subnet containing the NAT gateway should have a 0.0.0.0/0 route pointing to the internet gateway. For more information, see Configure DNS64 and NAT64 in the User Guide.

enable_lni_at_device_index

Indicates the device position for local network interfaces in this subnet. For example, 1 indicates local network interfaces in this subnet are the secondary network interface (eth1).

ipv4_ipam_pool_id

An IPv4 IPAM pool ID for the subnet.

ipv4_netmask_length

An IPv4 netmask length for the subnet.

ipv6_cidr_block

The IPv6 CIDR block. If you specify AssignIpv6AddressOnCreation, you must also specify an IPv6 CIDR block.

ipv6_ipam_pool_id

An IPv6 IPAM pool ID for the subnet.

ipv6_native

Indicates whether this is an IPv6 only subnet. For more information, see Subnet basics in the User Guide.

ipv6_netmask_length

An IPv6 netmask length for the subnet.

map_public_ip_on_launch

Indicates whether instances launched in this subnet receive a public IPv4 address. The default value is false. AWS charges for all public IPv4 addresses, including public IPv4 addresses associated with running instances and Elastic IP addresses. For more information, see the Public IPv4 Address tab on the VPC pricing page.

outpost_arn

The Amazon Resource Name (ARN) of the Outpost.

private_dns_name_options_on_launch

The hostname type for EC2 instances launched into this subnet and how DNS A and AAAA record queries to the instances should be handled. For more information, see Amazon EC2 instance hostname types in the User Guide. Available options: + EnableResourceNameDnsAAAARecord (true | false) + EnableResourceNameDnsARecord (true | false) + HostnameType (ip-name | resource-name)

tags

Any tags assigned to the subnet.

vpc_id

The ID of the VPC the subnet is in. If you update this property, you must also update the CidrBlock property.

Enum Values

block_public_access_states.internet_gateway_block_mode (InternetGatewayBlockMode)

Value DSL Identifier
off aws.ec2.Subnet.BlockPublicAccessStates.InternetGatewayBlockMode.off
block-bidirectional aws.ec2.Subnet.BlockPublicAccessStates.InternetGatewayBlockMode.block_bidirectional
block-ingress aws.ec2.Subnet.BlockPublicAccessStates.InternetGatewayBlockMode.block_ingress

Shorthand formats: off or InternetGatewayBlockMode.off

private_dns_name_options_on_launch.hostname_type (HostnameType)

Value DSL Identifier
ip-name aws.ec2.Subnet.PrivateDnsNameOptionsOnLaunch.HostnameType.ip_name
resource-name aws.ec2.Subnet.PrivateDnsNameOptionsOnLaunch.HostnameType.resource_name

Shorthand formats: ip_name or HostnameType.ip_name

Struct Definitions

block_public_access_states

Field Type Required Description
internet_gateway_block_mode Enum (InternetGatewayBlockMode) No The mode of VPC BPA. Options here are off, block-bidirectional, block-ingress

private_dns_name_options_on_launch

Field Type Required Description
enable_resource_name_dns_aaaa_record Bool No
enable_resource_name_dns_a_record Bool No
hostname_type Enum (HostnameType) No

Attribute Reference

block_public_access_states

ipv6_cidr_blocks

network_acl_association_id

subnet_id

AWS API narrowings

These fields are narrower than or equal to CFN. Input rules combine documented AWS domains, recorded live observations, and Carina canonical spellings for stable state comparison. A canonical DSL spelling does not claim AWS rejects other spellings. Attaching a type name adds no structural constraints. Field names below use CFN spelling.

CFN field Relation to CFN Evidence URL Verbatim quote / exact observation Checked / observed
/definitions/Tag/properties/Key Subset: CFN ∩ reviewed input domain Source record Maximum key length – 128 Unicode characters in UTF-8 2026-11-07
/definitions/Tag/properties/Value Subset: CFN ∩ reviewed input domain Source record The value of the tag.Constraints: Tag values are case-sensitive and accept a maximum of 256 Unicode characters. 2026-11-07
/properties/Ipv4NetmaskLength Subset: CFN ∩ reviewed input domain Source record The allowed IPv4 CIDR block size for a subnet is between a /28 netmask and /16 netmask. 2026-11-07
/properties/Ipv6NetmaskLength Subset: CFN ∩ reviewed input domain Source record If you've associated an IPv6 CIDR block with your VPC, you can associate an IPv6 CIDR block with an existing subnet in your VPC, or when you create a new subnet. Possible IPv6 netmask lengths are between /44 and /64 in increments of /4. 2026-11-07
/properties/PrivateDnsNameOptionsOnLaunch/properties/HostnameType Subset: CFN ∩ reviewed input domain Source record The type of hostname for EC2 instances. For IPv4 only subnets, an instance DNS name must be based on the instance IPv4 address. For IPv6 only subnets, an instance DNS name must be based on the instance ID. For dual-stack subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID.Allowed values: ip-name | resource-name 2026-11-07