Carina

Resource

aws.ec2.Subnet

Describes a subnet.

Example

let vpc = aws.ec2.Vpc {
  cidr_block = '10.0.0.0/16'

  tags = {
    Environment = 'example'
  }
}

aws.ec2.Subnet {
  vpc_id            = vpc.vpc_id
  cidr_block        = '10.0.1.0/24'
  availability_zone = aws.AvailabilityZone.ZoneName.ap_northeast_1a

  tags = {
    Environment = 'example'
  }
}

Argument Reference

assign_ipv6_address_on_creation

Indicates whether a network interface created in this subnet (including a network interface created by RunInstances) receives an IPv6 address.

availability_zone

The Availability Zone or Local Zone for the subnet. Default: Amazon Web Services selects one for you. If you create more than one subnet in your VPC, we do not necessarily select a different zone for each subnet. To create a subnet in a Local Zone, set this value to the Local Zone ID, for example us-west-2-lax-1a. For information about the Regions that support Local Zones, see Available Local Zones. To create a subnet in an Outpost, set this value to the Availability Zone for the Outpost and specify the Outpost ARN.

availability_zone_id

The AZ ID or the Local Zone ID of the subnet.

cidr_block

The IPv4 network range for the subnet, in CIDR notation. For example, 10.0.0.0/24. We modify the specified CIDR block to its canonical form; for example, if you specify 100.68.0.18/18, we modify it to 100.68.0.0/18. This parameter is not supported for an IPv6 only subnet.

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.

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 network range for the subnet, in CIDR notation. This parameter is required for an IPv6 only subnet.

ipv6_ipam_pool_id

An IPv6 IPAM pool ID for the subnet.

ipv6_native

Indicates whether to create an IPv6 only subnet.

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. Amazon Web Services 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 Amazon VPC pricing page.

outpost_arn

The Amazon Resource Name (ARN) of the Outpost. If you specify an Outpost ARN, you must also specify the Availability Zone of the Outpost subnet.

private_dns_name_options_on_launch

The type of hostnames to assign to instances in the subnet at launch. An instance hostname is based on the IPv4 address or ID of the instance.

vpc_id

The ID of the VPC.

tags

The tags for the resource.

Enum Values

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

private_dns_name_options_on_launch

Field Type Required Description
enable_resource_name_dns_aaaa_record Bool No Indicates whether to respond to DNS queries for instance hostname with DNS AAAA records.
enable_resource_name_dns_a_record Bool No Indicates whether to respond to DNS queries for instance hostnames with DNS A records.
hostname_type HostnameType No 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.

Attribute Reference

subnet_id

The ID of the subnet.