AWS Native is in preview. AWS Classic is fully supported.
aws-native.ec2.Subnet
Explore with Pulumi AI
AWS Native is in preview. AWS Classic is fully supported.
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.
Create Subnet Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Subnet(name: string, args: SubnetArgs, opts?: CustomResourceOptions);
@overload
def Subnet(resource_name: str,
args: SubnetArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Subnet(resource_name: str,
opts: Optional[ResourceOptions] = None,
vpc_id: Optional[str] = None,
ipv6_cidr_block: Optional[str] = None,
enable_lni_at_device_index: Optional[int] = None,
ipv6_cidr_blocks: Optional[Sequence[str]] = None,
enable_dns64: Optional[bool] = None,
ipv6_ipam_pool_id: Optional[str] = None,
ipv4_ipam_pool_id: Optional[str] = None,
ipv4_netmask_length: Optional[int] = None,
ipv6_native: Optional[bool] = None,
cidr_block: Optional[str] = None,
availability_zone_id: Optional[str] = None,
assign_ipv6_address_on_creation: Optional[bool] = None,
ipv6_netmask_length: Optional[int] = None,
map_public_ip_on_launch: Optional[bool] = None,
outpost_arn: Optional[str] = None,
private_dns_name_options_on_launch: Optional[PrivateDnsNameOptionsOnLaunchPropertiesArgs] = None,
tags: Optional[Sequence[_root_inputs.TagArgs]] = None,
availability_zone: Optional[str] = None)
func NewSubnet(ctx *Context, name string, args SubnetArgs, opts ...ResourceOption) (*Subnet, error)
public Subnet(string name, SubnetArgs args, CustomResourceOptions? opts = null)
public Subnet(String name, SubnetArgs args)
public Subnet(String name, SubnetArgs args, CustomResourceOptions options)
type: aws-native:ec2:Subnet
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Subnet Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The Subnet resource accepts the following input properties:
- 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
Ipv6Address boolOn Creation - Indicates whether a network interface created in this subnet receives an IPv6 address. The default value is
false
. If you specifyAssignIpv6AddressOnCreation
, 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 stringId - 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
Dns64 bool - 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 intAt 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). - Ipv4Ipam
Pool stringId - An IPv4 IPAM pool ID for the subnet.
- Ipv4Netmask
Length int - An IPv4 netmask length for the subnet.
- Ipv6Cidr
Block string - The IPv6 CIDR block.
If you specify
AssignIpv6AddressOnCreation
, you must also specify an IPv6 CIDR block. - Ipv6Cidr
Blocks List<string> - The IPv6 network ranges for the subnet, in CIDR notation.
- Ipv6Ipam
Pool stringId - An IPv6 IPAM pool ID for the subnet.
- Ipv6Native bool
- Indicates whether this is an IPv6 only subnet. For more information, see Subnet basics in the User Guide.
- Ipv6Netmask
Length int - An IPv6 netmask length for the subnet.
- Map
Public boolIp 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 string - The Amazon Resource Name (ARN) of the Outpost.
- Private
Dns Pulumi.Name Options On Launch Aws Native. Ec2. Inputs. Private Dns Name Options On Launch Properties - 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)
- List<Pulumi.
Aws Native. Inputs. Tag> - Any tags assigned to the subnet.
- 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
Ipv6Address boolOn Creation - Indicates whether a network interface created in this subnet receives an IPv6 address. The default value is
false
. If you specifyAssignIpv6AddressOnCreation
, 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 stringId - 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
Dns64 bool - 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 intAt 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). - Ipv4Ipam
Pool stringId - An IPv4 IPAM pool ID for the subnet.
- Ipv4Netmask
Length int - An IPv4 netmask length for the subnet.
- Ipv6Cidr
Block string - The IPv6 CIDR block.
If you specify
AssignIpv6AddressOnCreation
, you must also specify an IPv6 CIDR block. - Ipv6Cidr
Blocks []string - The IPv6 network ranges for the subnet, in CIDR notation.
- Ipv6Ipam
Pool stringId - An IPv6 IPAM pool ID for the subnet.
- Ipv6Native bool
- Indicates whether this is an IPv6 only subnet. For more information, see Subnet basics in the User Guide.
- Ipv6Netmask
Length int - An IPv6 netmask length for the subnet.
- Map
Public boolIp 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 string - The Amazon Resource Name (ARN) of the Outpost.
- Private
Dns PrivateName Options On Launch Dns Name Options On Launch Properties Args - 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)
- Tag
Args - Any tags assigned to the subnet.
- 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
Ipv6Address BooleanOn Creation - Indicates whether a network interface created in this subnet receives an IPv6 address. The default value is
false
. If you specifyAssignIpv6AddressOnCreation
, 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 StringId - 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
Dns64 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 IntegerAt 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). - ipv4Ipam
Pool StringId - An IPv4 IPAM pool ID for the subnet.
- ipv4Netmask
Length Integer - An IPv4 netmask length for the subnet.
- ipv6Cidr
Block String - The IPv6 CIDR block.
If you specify
AssignIpv6AddressOnCreation
, you must also specify an IPv6 CIDR block. - ipv6Cidr
Blocks List<String> - The IPv6 network ranges for the subnet, in CIDR notation.
- ipv6Ipam
Pool StringId - An IPv6 IPAM pool ID for the subnet.
- ipv6Native Boolean
- Indicates whether this is an IPv6 only subnet. For more information, see Subnet basics in the User Guide.
- ipv6Netmask
Length Integer - An IPv6 netmask length for the subnet.
- map
Public BooleanIp 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 String - The Amazon Resource Name (ARN) of the Outpost.
- private
Dns PrivateName Options On Launch Dns Name Options On Launch Properties - 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)
- List<Tag>
- Any tags assigned to the subnet.
- 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
Ipv6Address booleanOn Creation - Indicates whether a network interface created in this subnet receives an IPv6 address. The default value is
false
. If you specifyAssignIpv6AddressOnCreation
, 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 stringId - 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
Dns64 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 numberAt 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). - ipv4Ipam
Pool stringId - An IPv4 IPAM pool ID for the subnet.
- ipv4Netmask
Length number - An IPv4 netmask length for the subnet.
- ipv6Cidr
Block string - The IPv6 CIDR block.
If you specify
AssignIpv6AddressOnCreation
, you must also specify an IPv6 CIDR block. - ipv6Cidr
Blocks string[] - The IPv6 network ranges for the subnet, in CIDR notation.
- ipv6Ipam
Pool stringId - An IPv6 IPAM pool ID for the subnet.
- ipv6Native boolean
- Indicates whether this is an IPv6 only subnet. For more information, see Subnet basics in the User Guide.
- ipv6Netmask
Length number - An IPv6 netmask length for the subnet.
- map
Public booleanIp 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 string - The Amazon Resource Name (ARN) of the Outpost.
- private
Dns PrivateName Options On Launch Dns Name Options On Launch Properties - 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)
- Tag[]
- Any tags assigned to the subnet.
- vpc_
id str - The ID of the VPC the subnet is in.
If you update this property, you must also update the
CidrBlock
property. - assign_
ipv6_ booladdress_ on_ creation - Indicates whether a network interface created in this subnet receives an IPv6 address. The default value is
false
. If you specifyAssignIpv6AddressOnCreation
, you must also specify an IPv6 CIDR block. - availability_
zone str - The Availability Zone of the subnet.
If you update this property, you must also update the
CidrBlock
property. - availability_
zone_ strid - The AZ ID of the subnet.
- cidr_
block str - 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 bool - 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_ intat_ 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_ strpool_ id - An IPv4 IPAM pool ID for the subnet.
- ipv4_
netmask_ intlength - An IPv4 netmask length for the subnet.
- ipv6_
cidr_ strblock - The IPv6 CIDR block.
If you specify
AssignIpv6AddressOnCreation
, you must also specify an IPv6 CIDR block. - ipv6_
cidr_ Sequence[str]blocks - The IPv6 network ranges for the subnet, in CIDR notation.
- ipv6_
ipam_ strpool_ id - An IPv6 IPAM pool ID for the subnet.
- ipv6_
native bool - Indicates whether this is an IPv6 only subnet. For more information, see Subnet basics in the User Guide.
- ipv6_
netmask_ intlength - An IPv6 netmask length for the subnet.
- map_
public_ boolip_ 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 str - The Amazon Resource Name (ARN) of the Outpost.
- private_
dns_ Privatename_ options_ on_ launch Dns Name Options On Launch Properties Args - 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)
- Sequence[Tag
Args] - Any tags assigned to the subnet.
- 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
Ipv6Address BooleanOn Creation - Indicates whether a network interface created in this subnet receives an IPv6 address. The default value is
false
. If you specifyAssignIpv6AddressOnCreation
, 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 StringId - 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
Dns64 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 NumberAt 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). - ipv4Ipam
Pool StringId - An IPv4 IPAM pool ID for the subnet.
- ipv4Netmask
Length Number - An IPv4 netmask length for the subnet.
- ipv6Cidr
Block String - The IPv6 CIDR block.
If you specify
AssignIpv6AddressOnCreation
, you must also specify an IPv6 CIDR block. - ipv6Cidr
Blocks List<String> - The IPv6 network ranges for the subnet, in CIDR notation.
- ipv6Ipam
Pool StringId - An IPv6 IPAM pool ID for the subnet.
- ipv6Native Boolean
- Indicates whether this is an IPv6 only subnet. For more information, see Subnet basics in the User Guide.
- ipv6Netmask
Length Number - An IPv6 netmask length for the subnet.
- map
Public BooleanIp 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 String - The Amazon Resource Name (ARN) of the Outpost.
- private
Dns Property MapName 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)
- List<Property Map>
- Any tags assigned to the subnet.
Outputs
All input properties are implicitly available as output properties. Additionally, the Subnet resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Network
Acl stringAssociation Id - The ID of the network ACL that is associated with the subnet's VPC, such as
acl-5fb85d36
. - Subnet
Id string - The ID of the subnet.
- Id string
- The provider-assigned unique ID for this managed resource.
- Network
Acl stringAssociation Id - The ID of the network ACL that is associated with the subnet's VPC, such as
acl-5fb85d36
. - Subnet
Id string - The ID of the subnet.
- id String
- The provider-assigned unique ID for this managed resource.
- network
Acl StringAssociation Id - The ID of the network ACL that is associated with the subnet's VPC, such as
acl-5fb85d36
. - subnet
Id String - The ID of the subnet.
- id string
- The provider-assigned unique ID for this managed resource.
- network
Acl stringAssociation Id - The ID of the network ACL that is associated with the subnet's VPC, such as
acl-5fb85d36
. - subnet
Id string - The ID of the subnet.
- id str
- The provider-assigned unique ID for this managed resource.
- network_
acl_ strassociation_ id - The ID of the network ACL that is associated with the subnet's VPC, such as
acl-5fb85d36
. - subnet_
id str - The ID of the subnet.
- id String
- The provider-assigned unique ID for this managed resource.
- network
Acl StringAssociation Id - The ID of the network ACL that is associated with the subnet's VPC, such as
acl-5fb85d36
. - subnet
Id String - The ID of the subnet.
Supporting Types
PrivateDnsNameOptionsOnLaunchProperties, PrivateDnsNameOptionsOnLaunchPropertiesArgs
- Enable
Resource boolName Dns ARecord - Indicates whether to respond to DNS queries for instance hostnames with DNS A records.
- Enable
Resource boolName Dns Aaaa Record - Indicates whether to respond to DNS queries for instance hostname with DNS AAAA records.
- Hostname
Type string - 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.
- Enable
Resource boolName Dns ARecord - Indicates whether to respond to DNS queries for instance hostnames with DNS A records.
- Enable
Resource boolName Dns Aaaa Record - Indicates whether to respond to DNS queries for instance hostname with DNS AAAA records.
- Hostname
Type string - 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.
- enable
Resource BooleanName Dns ARecord - Indicates whether to respond to DNS queries for instance hostnames with DNS A records.
- enable
Resource BooleanName Dns Aaaa Record - Indicates whether to respond to DNS queries for instance hostname with DNS AAAA records.
- hostname
Type String - 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.
- enable
Resource booleanName Dns ARecord - Indicates whether to respond to DNS queries for instance hostnames with DNS A records.
- enable
Resource booleanName Dns Aaaa Record - Indicates whether to respond to DNS queries for instance hostname with DNS AAAA records.
- hostname
Type string - 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.
- enable_
resource_ boolname_ dns_ a_ record - Indicates whether to respond to DNS queries for instance hostnames with DNS A records.
- enable_
resource_ boolname_ dns_ aaaa_ record - Indicates whether to respond to DNS queries for instance hostname with DNS AAAA records.
- hostname_
type str - 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.
- enable
Resource BooleanName Dns ARecord - Indicates whether to respond to DNS queries for instance hostnames with DNS A records.
- enable
Resource BooleanName Dns Aaaa Record - Indicates whether to respond to DNS queries for instance hostname with DNS AAAA records.
- hostname
Type String - 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.
Tag, TagArgs
Package Details
- Repository
- AWS Native pulumi/pulumi-aws-native
- License
- Apache-2.0
AWS Native is in preview. AWS Classic is fully supported.