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.
To create a subnet in a VPC
resource "awscc_ec2_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
resource "awscc_ec2_subnet" "main" {
vpc_id = resource.awscc_ec2_vpc.main.id
cidr_block = "10.0.1.0/24"
tags = [{
key = "Modified By"
value = "AWSCC"
}]
}
vpc_id
(String) The ID of the VPC the subnet is in.
If you update this property, you must also update the CidrBlock
property.assign_ipv_6_address_on_creation
(Boolean) 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
(String) The Availability Zone of the subnet.
If you update this property, you must also update the CidrBlock
property.availability_zone_id
(String) The AZ ID of the subnet.cidr_block
(String) 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_dns_64
(Boolean) Indicates whether DNS queries made to the Amazon-provided DNS Resolver in this subnet should return synthetic IPv6 addresses for IPv4-only destinations. For more information, see DNS64 and NAT64 in the User Guide.enable_lni_at_device_index
(Number) 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).ipv_4_ipam_pool_id
(String) An IPv4 IPAM pool ID for the subnet.ipv_4_netmask_length
(Number) An IPv4 netmask length for the subnet.ipv_6_cidr_block
(String) The IPv6 CIDR block.
If you specify AssignIpv6AddressOnCreation
, you must also specify an IPv6 CIDR block.ipv_6_cidr_blocks
(List of String) The IPv6 network ranges for the subnet, in CIDR notation.ipv_6_ipam_pool_id
(String) An IPv6 IPAM pool ID for the subnet.ipv_6_native
(Boolean) Indicates whether this is an IPv6 only subnet. For more information, see Subnet basics in the User Guide.ipv_6_netmask_length
(Number) An IPv6 netmask length for the subnet.map_public_ip_on_launch
(Boolean) 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
(String) The Amazon Resource Name (ARN) of the Outpost.private_dns_name_options_on_launch
(Attributes) 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:
tags
(Attributes List) Any tags assigned to the subnet. (see below for nested schema)id
(String) Uniquely identifies the resource.network_acl_association_id
(String)subnet_id
(String)private_dns_name_options_on_launch
Optional:
enable_resource_name_dns_a_record
(Boolean)enable_resource_name_dns_aaaa_record
(Boolean)hostname_type
(String)tags
Required:
key
(String) The tag key.value
(String) The tag value.Import is supported using the following syntax:
$ terraform import awscc_ec2_subnet.example <resource ID>