AWS Classic v5.41.0, May 15 23
AWS Classic v5.41.0, May 15 23
aws.ec2.Subnet
Explore with Pulumi AI
Provides an VPC subnet resource.
NOTE: Due to AWS Lambda improved VPC networking changes that began deploying in September 2019, subnets associated with Lambda Functions can take up to 45 minutes to successfully delete.
Example Usage
Basic Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var main = new Aws.Ec2.Subnet("main", new()
{
VpcId = aws_vpc.Main.Id,
CidrBlock = "10.0.1.0/24",
Tags =
{
{ "Name", "Main" },
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ec2.NewSubnet(ctx, "main", &ec2.SubnetArgs{
VpcId: pulumi.Any(aws_vpc.Main.Id),
CidrBlock: pulumi.String("10.0.1.0/24"),
Tags: pulumi.StringMap{
"Name": pulumi.String("Main"),
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Subnet;
import com.pulumi.aws.ec2.SubnetArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var main = new Subnet("main", SubnetArgs.builder()
.vpcId(aws_vpc.main().id())
.cidrBlock("10.0.1.0/24")
.tags(Map.of("Name", "Main"))
.build());
}
}
import pulumi
import pulumi_aws as aws
main = aws.ec2.Subnet("main",
vpc_id=aws_vpc["main"]["id"],
cidr_block="10.0.1.0/24",
tags={
"Name": "Main",
})
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const main = new aws.ec2.Subnet("main", {
vpcId: aws_vpc.main.id,
cidrBlock: "10.0.1.0/24",
tags: {
Name: "Main",
},
});
resources:
main:
type: aws:ec2:Subnet
properties:
vpcId: ${aws_vpc.main.id}
cidrBlock: 10.0.1.0/24
tags:
Name: Main
Subnets In Secondary VPC CIDR Blocks
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var secondaryCidr = new Aws.Ec2.VpcIpv4CidrBlockAssociation("secondaryCidr", new()
{
VpcId = aws_vpc.Main.Id,
CidrBlock = "172.2.0.0/16",
});
var inSecondaryCidr = new Aws.Ec2.Subnet("inSecondaryCidr", new()
{
VpcId = secondaryCidr.VpcId,
CidrBlock = "172.2.0.0/24",
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
secondaryCidr, err := ec2.NewVpcIpv4CidrBlockAssociation(ctx, "secondaryCidr", &ec2.VpcIpv4CidrBlockAssociationArgs{
VpcId: pulumi.Any(aws_vpc.Main.Id),
CidrBlock: pulumi.String("172.2.0.0/16"),
})
if err != nil {
return err
}
_, err = ec2.NewSubnet(ctx, "inSecondaryCidr", &ec2.SubnetArgs{
VpcId: secondaryCidr.VpcId,
CidrBlock: pulumi.String("172.2.0.0/24"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.VpcIpv4CidrBlockAssociation;
import com.pulumi.aws.ec2.VpcIpv4CidrBlockAssociationArgs;
import com.pulumi.aws.ec2.Subnet;
import com.pulumi.aws.ec2.SubnetArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var secondaryCidr = new VpcIpv4CidrBlockAssociation("secondaryCidr", VpcIpv4CidrBlockAssociationArgs.builder()
.vpcId(aws_vpc.main().id())
.cidrBlock("172.2.0.0/16")
.build());
var inSecondaryCidr = new Subnet("inSecondaryCidr", SubnetArgs.builder()
.vpcId(secondaryCidr.vpcId())
.cidrBlock("172.2.0.0/24")
.build());
}
}
import pulumi
import pulumi_aws as aws
secondary_cidr = aws.ec2.VpcIpv4CidrBlockAssociation("secondaryCidr",
vpc_id=aws_vpc["main"]["id"],
cidr_block="172.2.0.0/16")
in_secondary_cidr = aws.ec2.Subnet("inSecondaryCidr",
vpc_id=secondary_cidr.vpc_id,
cidr_block="172.2.0.0/24")
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const secondaryCidr = new aws.ec2.VpcIpv4CidrBlockAssociation("secondaryCidr", {
vpcId: aws_vpc.main.id,
cidrBlock: "172.2.0.0/16",
});
const inSecondaryCidr = new aws.ec2.Subnet("inSecondaryCidr", {
vpcId: secondaryCidr.vpcId,
cidrBlock: "172.2.0.0/24",
});
resources:
secondaryCidr:
type: aws:ec2:VpcIpv4CidrBlockAssociation
properties:
vpcId: ${aws_vpc.main.id}
cidrBlock: 172.2.0.0/16
inSecondaryCidr:
type: aws:ec2:Subnet
properties:
vpcId: ${secondaryCidr.vpcId}
cidrBlock: 172.2.0.0/24
Create Subnet Resource
new Subnet(name: string, args: SubnetArgs, opts?: CustomResourceOptions);
@overload
def Subnet(resource_name: str,
opts: Optional[ResourceOptions] = None,
assign_ipv6_address_on_creation: Optional[bool] = None,
availability_zone: Optional[str] = None,
availability_zone_id: Optional[str] = None,
cidr_block: Optional[str] = None,
customer_owned_ipv4_pool: Optional[str] = None,
enable_dns64: Optional[bool] = None,
enable_lni_at_device_index: Optional[int] = None,
enable_resource_name_dns_a_record_on_launch: Optional[bool] = None,
enable_resource_name_dns_aaaa_record_on_launch: Optional[bool] = None,
ipv6_cidr_block: Optional[str] = None,
ipv6_native: Optional[bool] = None,
map_customer_owned_ip_on_launch: Optional[bool] = None,
map_public_ip_on_launch: Optional[bool] = None,
outpost_arn: Optional[str] = None,
private_dns_hostname_type_on_launch: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
vpc_id: Optional[str] = None)
@overload
def Subnet(resource_name: str,
args: SubnetArgs,
opts: Optional[ResourceOptions] = 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:ec2:Subnet
properties: # The arguments to resource properties.
options: # 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.
- 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 VPC ID.
- Assign
Ipv6Address boolOn Creation Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is
false
- Availability
Zone string AZ for the subnet.
- Availability
Zone stringId AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use
availability_zone
instead.- Cidr
Block string The IPv4 CIDR block for the subnet.
- Customer
Owned stringIpv4Pool The customer owned IPv4 address pool. Typically used with the
map_customer_owned_ip_on_launch
argument. Theoutpost_arn
argument must be specified when configured.- 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. Default:
false
.- 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). A local network interface cannot be the primary network interface (eth0).
- Enable
Resource boolName Dns ARecord On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default:
false
.- Enable
Resource boolName Dns Aaaa Record On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default:
false
.- Ipv6Cidr
Block string The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
- Ipv6Native bool
Indicates whether to create an IPv6-only subnet. Default:
false
.- Map
Customer boolOwned Ip On Launch Specify
true
to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. Thecustomer_owned_ipv4_pool
andoutpost_arn
arguments must be specified when set totrue
. Default isfalse
.- Map
Public boolIp On Launch Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is
false
.- Outpost
Arn string The Amazon Resource Name (ARN) of the Outpost.
- Private
Dns stringHostname Type On Launch The type of hostnames to assign to instances in the subnet at launch. For IPv6-only subnets, an instance DNS name must be based on the instance ID. For dual-stack and IPv4-only subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID. Valid values:
ip-name
,resource-name
.- Dictionary<string, string>
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
- Vpc
Id string The VPC ID.
- Assign
Ipv6Address boolOn Creation Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is
false
- Availability
Zone string AZ for the subnet.
- Availability
Zone stringId AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use
availability_zone
instead.- Cidr
Block string The IPv4 CIDR block for the subnet.
- Customer
Owned stringIpv4Pool The customer owned IPv4 address pool. Typically used with the
map_customer_owned_ip_on_launch
argument. Theoutpost_arn
argument must be specified when configured.- 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. Default:
false
.- 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). A local network interface cannot be the primary network interface (eth0).
- Enable
Resource boolName Dns ARecord On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default:
false
.- Enable
Resource boolName Dns Aaaa Record On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default:
false
.- Ipv6Cidr
Block string The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
- Ipv6Native bool
Indicates whether to create an IPv6-only subnet. Default:
false
.- Map
Customer boolOwned Ip On Launch Specify
true
to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. Thecustomer_owned_ipv4_pool
andoutpost_arn
arguments must be specified when set totrue
. Default isfalse
.- Map
Public boolIp On Launch Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is
false
.- Outpost
Arn string The Amazon Resource Name (ARN) of the Outpost.
- Private
Dns stringHostname Type On Launch The type of hostnames to assign to instances in the subnet at launch. For IPv6-only subnets, an instance DNS name must be based on the instance ID. For dual-stack and IPv4-only subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID. Valid values:
ip-name
,resource-name
.- map[string]string
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
- vpc
Id String The VPC ID.
- assign
Ipv6Address BooleanOn Creation Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is
false
- availability
Zone String AZ for the subnet.
- availability
Zone StringId AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use
availability_zone
instead.- cidr
Block String The IPv4 CIDR block for the subnet.
- customer
Owned StringIpv4Pool The customer owned IPv4 address pool. Typically used with the
map_customer_owned_ip_on_launch
argument. Theoutpost_arn
argument must be specified when configured.- 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. Default:
false
.- 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). A local network interface cannot be the primary network interface (eth0).
- enable
Resource BooleanName Dns ARecord On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default:
false
.- enable
Resource BooleanName Dns Aaaa Record On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default:
false
.- ipv6Cidr
Block String The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
- ipv6Native Boolean
Indicates whether to create an IPv6-only subnet. Default:
false
.- map
Customer BooleanOwned Ip On Launch Specify
true
to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. Thecustomer_owned_ipv4_pool
andoutpost_arn
arguments must be specified when set totrue
. Default isfalse
.- map
Public BooleanIp On Launch Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is
false
.- outpost
Arn String The Amazon Resource Name (ARN) of the Outpost.
- private
Dns StringHostname Type On Launch The type of hostnames to assign to instances in the subnet at launch. For IPv6-only subnets, an instance DNS name must be based on the instance ID. For dual-stack and IPv4-only subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID. Valid values:
ip-name
,resource-name
.- Map<String,String>
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
- vpc
Id string The VPC ID.
- assign
Ipv6Address booleanOn Creation Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is
false
- availability
Zone string AZ for the subnet.
- availability
Zone stringId AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use
availability_zone
instead.- cidr
Block string The IPv4 CIDR block for the subnet.
- customer
Owned stringIpv4Pool The customer owned IPv4 address pool. Typically used with the
map_customer_owned_ip_on_launch
argument. Theoutpost_arn
argument must be specified when configured.- 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. Default:
false
.- 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). A local network interface cannot be the primary network interface (eth0).
- enable
Resource booleanName Dns ARecord On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default:
false
.- enable
Resource booleanName Dns Aaaa Record On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default:
false
.- ipv6Cidr
Block string The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
- ipv6Native boolean
Indicates whether to create an IPv6-only subnet. Default:
false
.- map
Customer booleanOwned Ip On Launch Specify
true
to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. Thecustomer_owned_ipv4_pool
andoutpost_arn
arguments must be specified when set totrue
. Default isfalse
.- map
Public booleanIp On Launch Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is
false
.- outpost
Arn string The Amazon Resource Name (ARN) of the Outpost.
- private
Dns stringHostname Type On Launch The type of hostnames to assign to instances in the subnet at launch. For IPv6-only subnets, an instance DNS name must be based on the instance ID. For dual-stack and IPv4-only subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID. Valid values:
ip-name
,resource-name
.- {[key: string]: string}
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
- vpc_
id str The VPC ID.
- assign_
ipv6_ booladdress_ on_ creation Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is
false
- availability_
zone str AZ for the subnet.
- availability_
zone_ strid AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use
availability_zone
instead.- cidr_
block str The IPv4 CIDR block for the subnet.
- customer_
owned_ stripv4_ pool The customer owned IPv4 address pool. Typically used with the
map_customer_owned_ip_on_launch
argument. Theoutpost_arn
argument must be specified when configured.- 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. Default:
false
.- 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). A local network interface cannot be the primary network interface (eth0).
- enable_
resource_ boolname_ dns_ a_ record_ on_ launch Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default:
false
.- enable_
resource_ boolname_ dns_ aaaa_ record_ on_ launch Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default:
false
.- ipv6_
cidr_ strblock The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
- ipv6_
native bool Indicates whether to create an IPv6-only subnet. Default:
false
.- map_
customer_ boolowned_ ip_ on_ launch Specify
true
to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. Thecustomer_owned_ipv4_pool
andoutpost_arn
arguments must be specified when set totrue
. Default isfalse
.- map_
public_ boolip_ on_ launch Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is
false
.- outpost_
arn str The Amazon Resource Name (ARN) of the Outpost.
- private_
dns_ strhostname_ type_ on_ launch The type of hostnames to assign to instances in the subnet at launch. For IPv6-only subnets, an instance DNS name must be based on the instance ID. For dual-stack and IPv4-only subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID. Valid values:
ip-name
,resource-name
.- Mapping[str, str]
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
- vpc
Id String The VPC ID.
- assign
Ipv6Address BooleanOn Creation Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is
false
- availability
Zone String AZ for the subnet.
- availability
Zone StringId AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use
availability_zone
instead.- cidr
Block String The IPv4 CIDR block for the subnet.
- customer
Owned StringIpv4Pool The customer owned IPv4 address pool. Typically used with the
map_customer_owned_ip_on_launch
argument. Theoutpost_arn
argument must be specified when configured.- 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. Default:
false
.- 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). A local network interface cannot be the primary network interface (eth0).
- enable
Resource BooleanName Dns ARecord On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default:
false
.- enable
Resource BooleanName Dns Aaaa Record On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default:
false
.- ipv6Cidr
Block String The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
- ipv6Native Boolean
Indicates whether to create an IPv6-only subnet. Default:
false
.- map
Customer BooleanOwned Ip On Launch Specify
true
to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. Thecustomer_owned_ipv4_pool
andoutpost_arn
arguments must be specified when set totrue
. Default isfalse
.- map
Public BooleanIp On Launch Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is
false
.- outpost
Arn String The Amazon Resource Name (ARN) of the Outpost.
- private
Dns StringHostname Type On Launch The type of hostnames to assign to instances in the subnet at launch. For IPv6-only subnets, an instance DNS name must be based on the instance ID. For dual-stack and IPv4-only subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID. Valid values:
ip-name
,resource-name
.- Map<String>
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Outputs
All input properties are implicitly available as output properties. Additionally, the Subnet resource produces the following output properties:
- Arn string
The ARN of the subnet.
- Id string
The provider-assigned unique ID for this managed resource.
- Ipv6Cidr
Block stringAssociation Id The association ID for the IPv6 CIDR block.
- Owner
Id string The ID of the AWS account that owns the subnet.
- Dictionary<string, string>
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.
- Arn string
The ARN of the subnet.
- Id string
The provider-assigned unique ID for this managed resource.
- Ipv6Cidr
Block stringAssociation Id The association ID for the IPv6 CIDR block.
- Owner
Id string The ID of the AWS account that owns the subnet.
- map[string]string
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.
- arn String
The ARN of the subnet.
- id String
The provider-assigned unique ID for this managed resource.
- ipv6Cidr
Block StringAssociation Id The association ID for the IPv6 CIDR block.
- owner
Id String The ID of the AWS account that owns the subnet.
- Map<String,String>
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.
- arn string
The ARN of the subnet.
- id string
The provider-assigned unique ID for this managed resource.
- ipv6Cidr
Block stringAssociation Id The association ID for the IPv6 CIDR block.
- owner
Id string The ID of the AWS account that owns the subnet.
- {[key: string]: string}
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.
- arn str
The ARN of the subnet.
- id str
The provider-assigned unique ID for this managed resource.
- ipv6_
cidr_ strblock_ association_ id The association ID for the IPv6 CIDR block.
- owner_
id str The ID of the AWS account that owns the subnet.
- Mapping[str, str]
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.
- arn String
The ARN of the subnet.
- id String
The provider-assigned unique ID for this managed resource.
- ipv6Cidr
Block StringAssociation Id The association ID for the IPv6 CIDR block.
- owner
Id String The ID of the AWS account that owns the subnet.
- Map<String>
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.
Look up Existing Subnet Resource
Get an existing Subnet resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: SubnetState, opts?: CustomResourceOptions): Subnet
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
arn: Optional[str] = None,
assign_ipv6_address_on_creation: Optional[bool] = None,
availability_zone: Optional[str] = None,
availability_zone_id: Optional[str] = None,
cidr_block: Optional[str] = None,
customer_owned_ipv4_pool: Optional[str] = None,
enable_dns64: Optional[bool] = None,
enable_lni_at_device_index: Optional[int] = None,
enable_resource_name_dns_a_record_on_launch: Optional[bool] = None,
enable_resource_name_dns_aaaa_record_on_launch: Optional[bool] = None,
ipv6_cidr_block: Optional[str] = None,
ipv6_cidr_block_association_id: Optional[str] = None,
ipv6_native: Optional[bool] = None,
map_customer_owned_ip_on_launch: Optional[bool] = None,
map_public_ip_on_launch: Optional[bool] = None,
outpost_arn: Optional[str] = None,
owner_id: Optional[str] = None,
private_dns_hostname_type_on_launch: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
tags_all: Optional[Mapping[str, str]] = None,
vpc_id: Optional[str] = None) -> Subnet
func GetSubnet(ctx *Context, name string, id IDInput, state *SubnetState, opts ...ResourceOption) (*Subnet, error)
public static Subnet Get(string name, Input<string> id, SubnetState? state, CustomResourceOptions? opts = null)
public static Subnet get(String name, Output<String> id, SubnetState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Arn string
The ARN of the subnet.
- Assign
Ipv6Address boolOn Creation Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is
false
- Availability
Zone string AZ for the subnet.
- Availability
Zone stringId AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use
availability_zone
instead.- Cidr
Block string The IPv4 CIDR block for the subnet.
- Customer
Owned stringIpv4Pool The customer owned IPv4 address pool. Typically used with the
map_customer_owned_ip_on_launch
argument. Theoutpost_arn
argument must be specified when configured.- 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. Default:
false
.- 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). A local network interface cannot be the primary network interface (eth0).
- Enable
Resource boolName Dns ARecord On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default:
false
.- Enable
Resource boolName Dns Aaaa Record On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default:
false
.- Ipv6Cidr
Block string The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
- Ipv6Cidr
Block stringAssociation Id The association ID for the IPv6 CIDR block.
- Ipv6Native bool
Indicates whether to create an IPv6-only subnet. Default:
false
.- Map
Customer boolOwned Ip On Launch Specify
true
to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. Thecustomer_owned_ipv4_pool
andoutpost_arn
arguments must be specified when set totrue
. Default isfalse
.- Map
Public boolIp On Launch Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is
false
.- Outpost
Arn string The Amazon Resource Name (ARN) of the Outpost.
- Owner
Id string The ID of the AWS account that owns the subnet.
- Private
Dns stringHostname Type On Launch The type of hostnames to assign to instances in the subnet at launch. For IPv6-only subnets, an instance DNS name must be based on the instance ID. For dual-stack and IPv4-only subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID. Valid values:
ip-name
,resource-name
.- Dictionary<string, string>
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.- Dictionary<string, string>
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.- Vpc
Id string The VPC ID.
- Arn string
The ARN of the subnet.
- Assign
Ipv6Address boolOn Creation Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is
false
- Availability
Zone string AZ for the subnet.
- Availability
Zone stringId AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use
availability_zone
instead.- Cidr
Block string The IPv4 CIDR block for the subnet.
- Customer
Owned stringIpv4Pool The customer owned IPv4 address pool. Typically used with the
map_customer_owned_ip_on_launch
argument. Theoutpost_arn
argument must be specified when configured.- 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. Default:
false
.- 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). A local network interface cannot be the primary network interface (eth0).
- Enable
Resource boolName Dns ARecord On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default:
false
.- Enable
Resource boolName Dns Aaaa Record On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default:
false
.- Ipv6Cidr
Block string The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
- Ipv6Cidr
Block stringAssociation Id The association ID for the IPv6 CIDR block.
- Ipv6Native bool
Indicates whether to create an IPv6-only subnet. Default:
false
.- Map
Customer boolOwned Ip On Launch Specify
true
to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. Thecustomer_owned_ipv4_pool
andoutpost_arn
arguments must be specified when set totrue
. Default isfalse
.- Map
Public boolIp On Launch Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is
false
.- Outpost
Arn string The Amazon Resource Name (ARN) of the Outpost.
- Owner
Id string The ID of the AWS account that owns the subnet.
- Private
Dns stringHostname Type On Launch The type of hostnames to assign to instances in the subnet at launch. For IPv6-only subnets, an instance DNS name must be based on the instance ID. For dual-stack and IPv4-only subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID. Valid values:
ip-name
,resource-name
.- map[string]string
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.- map[string]string
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.- Vpc
Id string The VPC ID.
- arn String
The ARN of the subnet.
- assign
Ipv6Address BooleanOn Creation Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is
false
- availability
Zone String AZ for the subnet.
- availability
Zone StringId AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use
availability_zone
instead.- cidr
Block String The IPv4 CIDR block for the subnet.
- customer
Owned StringIpv4Pool The customer owned IPv4 address pool. Typically used with the
map_customer_owned_ip_on_launch
argument. Theoutpost_arn
argument must be specified when configured.- 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. Default:
false
.- 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). A local network interface cannot be the primary network interface (eth0).
- enable
Resource BooleanName Dns ARecord On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default:
false
.- enable
Resource BooleanName Dns Aaaa Record On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default:
false
.- ipv6Cidr
Block String The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
- ipv6Cidr
Block StringAssociation Id The association ID for the IPv6 CIDR block.
- ipv6Native Boolean
Indicates whether to create an IPv6-only subnet. Default:
false
.- map
Customer BooleanOwned Ip On Launch Specify
true
to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. Thecustomer_owned_ipv4_pool
andoutpost_arn
arguments must be specified when set totrue
. Default isfalse
.- map
Public BooleanIp On Launch Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is
false
.- outpost
Arn String The Amazon Resource Name (ARN) of the Outpost.
- owner
Id String The ID of the AWS account that owns the subnet.
- private
Dns StringHostname Type On Launch The type of hostnames to assign to instances in the subnet at launch. For IPv6-only subnets, an instance DNS name must be based on the instance ID. For dual-stack and IPv4-only subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID. Valid values:
ip-name
,resource-name
.- Map<String,String>
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.- Map<String,String>
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.- vpc
Id String The VPC ID.
- arn string
The ARN of the subnet.
- assign
Ipv6Address booleanOn Creation Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is
false
- availability
Zone string AZ for the subnet.
- availability
Zone stringId AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use
availability_zone
instead.- cidr
Block string The IPv4 CIDR block for the subnet.
- customer
Owned stringIpv4Pool The customer owned IPv4 address pool. Typically used with the
map_customer_owned_ip_on_launch
argument. Theoutpost_arn
argument must be specified when configured.- 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. Default:
false
.- 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). A local network interface cannot be the primary network interface (eth0).
- enable
Resource booleanName Dns ARecord On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default:
false
.- enable
Resource booleanName Dns Aaaa Record On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default:
false
.- ipv6Cidr
Block string The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
- ipv6Cidr
Block stringAssociation Id The association ID for the IPv6 CIDR block.
- ipv6Native boolean
Indicates whether to create an IPv6-only subnet. Default:
false
.- map
Customer booleanOwned Ip On Launch Specify
true
to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. Thecustomer_owned_ipv4_pool
andoutpost_arn
arguments must be specified when set totrue
. Default isfalse
.- map
Public booleanIp On Launch Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is
false
.- outpost
Arn string The Amazon Resource Name (ARN) of the Outpost.
- owner
Id string The ID of the AWS account that owns the subnet.
- private
Dns stringHostname Type On Launch The type of hostnames to assign to instances in the subnet at launch. For IPv6-only subnets, an instance DNS name must be based on the instance ID. For dual-stack and IPv4-only subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID. Valid values:
ip-name
,resource-name
.- {[key: string]: string}
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.- {[key: string]: string}
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.- vpc
Id string The VPC ID.
- arn str
The ARN of the subnet.
- assign_
ipv6_ booladdress_ on_ creation Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is
false
- availability_
zone str AZ for the subnet.
- availability_
zone_ strid AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use
availability_zone
instead.- cidr_
block str The IPv4 CIDR block for the subnet.
- customer_
owned_ stripv4_ pool The customer owned IPv4 address pool. Typically used with the
map_customer_owned_ip_on_launch
argument. Theoutpost_arn
argument must be specified when configured.- 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. Default:
false
.- 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). A local network interface cannot be the primary network interface (eth0).
- enable_
resource_ boolname_ dns_ a_ record_ on_ launch Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default:
false
.- enable_
resource_ boolname_ dns_ aaaa_ record_ on_ launch Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default:
false
.- ipv6_
cidr_ strblock The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
- ipv6_
cidr_ strblock_ association_ id The association ID for the IPv6 CIDR block.
- ipv6_
native bool Indicates whether to create an IPv6-only subnet. Default:
false
.- map_
customer_ boolowned_ ip_ on_ launch Specify
true
to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. Thecustomer_owned_ipv4_pool
andoutpost_arn
arguments must be specified when set totrue
. Default isfalse
.- map_
public_ boolip_ on_ launch Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is
false
.- outpost_
arn str The Amazon Resource Name (ARN) of the Outpost.
- owner_
id str The ID of the AWS account that owns the subnet.
- private_
dns_ strhostname_ type_ on_ launch The type of hostnames to assign to instances in the subnet at launch. For IPv6-only subnets, an instance DNS name must be based on the instance ID. For dual-stack and IPv4-only subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID. Valid values:
ip-name
,resource-name
.- Mapping[str, str]
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.- Mapping[str, str]
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.- vpc_
id str The VPC ID.
- arn String
The ARN of the subnet.
- assign
Ipv6Address BooleanOn Creation Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is
false
- availability
Zone String AZ for the subnet.
- availability
Zone StringId AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use
availability_zone
instead.- cidr
Block String The IPv4 CIDR block for the subnet.
- customer
Owned StringIpv4Pool The customer owned IPv4 address pool. Typically used with the
map_customer_owned_ip_on_launch
argument. Theoutpost_arn
argument must be specified when configured.- 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. Default:
false
.- 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). A local network interface cannot be the primary network interface (eth0).
- enable
Resource BooleanName Dns ARecord On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default:
false
.- enable
Resource BooleanName Dns Aaaa Record On Launch Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default:
false
.- ipv6Cidr
Block String The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
- ipv6Cidr
Block StringAssociation Id The association ID for the IPv6 CIDR block.
- ipv6Native Boolean
Indicates whether to create an IPv6-only subnet. Default:
false
.- map
Customer BooleanOwned Ip On Launch Specify
true
to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. Thecustomer_owned_ipv4_pool
andoutpost_arn
arguments must be specified when set totrue
. Default isfalse
.- map
Public BooleanIp On Launch Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is
false
.- outpost
Arn String The Amazon Resource Name (ARN) of the Outpost.
- owner
Id String The ID of the AWS account that owns the subnet.
- private
Dns StringHostname Type On Launch The type of hostnames to assign to instances in the subnet at launch. For IPv6-only subnets, an instance DNS name must be based on the instance ID. For dual-stack and IPv4-only subnets, you can specify whether DNS names use the instance IPv4 address or the instance ID. Valid values:
ip-name
,resource-name
.- Map<String>
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.- Map<String>
A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block.- vpc
Id String The VPC ID.
Import
Subnets can be imported using the subnet id
, e.g.,
$ pulumi import aws:ec2/subnet:Subnet public_subnet subnet-9d4a7b6c
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
aws
Terraform Provider.