1. Packages
  2. AWS Classic
  3. API Docs
  4. ec2
  5. Subnet

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.28.1 published on Thursday, Mar 28, 2024 by Pulumi

aws.ec2.Subnet

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.28.1 published on Thursday, Mar 28, 2024 by Pulumi

    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

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const main = new aws.ec2.Subnet("main", {
        vpcId: mainAwsVpc.id,
        cidrBlock: "10.0.1.0/24",
        tags: {
            Name: "Main",
        },
    });
    
    import pulumi
    import pulumi_aws as aws
    
    main = aws.ec2.Subnet("main",
        vpc_id=main_aws_vpc["id"],
        cidr_block="10.0.1.0/24",
        tags={
            "Name": "Main",
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/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(mainAwsVpc.Id),
    			CidrBlock: pulumi.String("10.0.1.0/24"),
    			Tags: pulumi.StringMap{
    				"Name": pulumi.String("Main"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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 = mainAwsVpc.Id,
            CidrBlock = "10.0.1.0/24",
            Tags = 
            {
                { "Name", "Main" },
            },
        });
    
    });
    
    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(mainAwsVpc.id())
                .cidrBlock("10.0.1.0/24")
                .tags(Map.of("Name", "Main"))
                .build());
    
        }
    }
    
    resources:
      main:
        type: aws:ec2:Subnet
        properties:
          vpcId: ${mainAwsVpc.id}
          cidrBlock: 10.0.1.0/24
          tags:
            Name: Main
    

    Subnets In Secondary VPC CIDR Blocks

    When managing subnets in one of a VPC’s secondary CIDR blocks created using a aws.ec2.VpcIpv4CidrBlockAssociation resource, it is recommended to reference that resource’s vpc_id attribute to ensure correct dependency ordering.

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const secondaryCidr = new aws.ec2.VpcIpv4CidrBlockAssociation("secondary_cidr", {
        vpcId: main.id,
        cidrBlock: "172.20.0.0/16",
    });
    const inSecondaryCidr = new aws.ec2.Subnet("in_secondary_cidr", {
        vpcId: secondaryCidr.vpcId,
        cidrBlock: "172.20.0.0/24",
    });
    
    import pulumi
    import pulumi_aws as aws
    
    secondary_cidr = aws.ec2.VpcIpv4CidrBlockAssociation("secondary_cidr",
        vpc_id=main["id"],
        cidr_block="172.20.0.0/16")
    in_secondary_cidr = aws.ec2.Subnet("in_secondary_cidr",
        vpc_id=secondary_cidr.vpc_id,
        cidr_block="172.20.0.0/24")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/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, "secondary_cidr", &ec2.VpcIpv4CidrBlockAssociationArgs{
    			VpcId:     pulumi.Any(main.Id),
    			CidrBlock: pulumi.String("172.20.0.0/16"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = ec2.NewSubnet(ctx, "in_secondary_cidr", &ec2.SubnetArgs{
    			VpcId:     secondaryCidr.VpcId,
    			CidrBlock: pulumi.String("172.20.0.0/24"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var secondaryCidr = new Aws.Ec2.VpcIpv4CidrBlockAssociation("secondary_cidr", new()
        {
            VpcId = main.Id,
            CidrBlock = "172.20.0.0/16",
        });
    
        var inSecondaryCidr = new Aws.Ec2.Subnet("in_secondary_cidr", new()
        {
            VpcId = secondaryCidr.VpcId,
            CidrBlock = "172.20.0.0/24",
        });
    
    });
    
    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(main.id())
                .cidrBlock("172.20.0.0/16")
                .build());
    
            var inSecondaryCidr = new Subnet("inSecondaryCidr", SubnetArgs.builder()        
                .vpcId(secondaryCidr.vpcId())
                .cidrBlock("172.20.0.0/24")
                .build());
    
        }
    }
    
    resources:
      secondaryCidr:
        type: aws:ec2:VpcIpv4CidrBlockAssociation
        name: secondary_cidr
        properties:
          vpcId: ${main.id}
          cidrBlock: 172.20.0.0/16
      inSecondaryCidr:
        type: aws:ec2:Subnet
        name: in_secondary_cidr
        properties:
          vpcId: ${secondaryCidr.vpcId}
          cidrBlock: 172.20.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:

    VpcId string
    The VPC ID.
    AssignIpv6AddressOnCreation bool
    Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is false
    AvailabilityZone string
    AZ for the subnet.
    AvailabilityZoneId string
    AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use availability_zone instead.
    CidrBlock string
    The IPv4 CIDR block for the subnet.
    CustomerOwnedIpv4Pool string
    The customer owned IPv4 address pool. Typically used with the map_customer_owned_ip_on_launch argument. The outpost_arn argument must be specified when configured.
    EnableDns64 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.
    EnableLniAtDeviceIndex int
    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).
    EnableResourceNameDnsARecordOnLaunch bool
    Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false.
    EnableResourceNameDnsAaaaRecordOnLaunch bool
    Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false.
    Ipv6CidrBlock 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.
    MapCustomerOwnedIpOnLaunch bool
    Specify true to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. The customer_owned_ipv4_pool and outpost_arn arguments must be specified when set to true. Default is false.
    MapPublicIpOnLaunch bool
    Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is false.
    OutpostArn string
    The Amazon Resource Name (ARN) of the Outpost.
    PrivateDnsHostnameTypeOnLaunch string
    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.
    Tags 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.
    VpcId string
    The VPC ID.
    AssignIpv6AddressOnCreation bool
    Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is false
    AvailabilityZone string
    AZ for the subnet.
    AvailabilityZoneId string
    AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use availability_zone instead.
    CidrBlock string
    The IPv4 CIDR block for the subnet.
    CustomerOwnedIpv4Pool string
    The customer owned IPv4 address pool. Typically used with the map_customer_owned_ip_on_launch argument. The outpost_arn argument must be specified when configured.
    EnableDns64 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.
    EnableLniAtDeviceIndex int
    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).
    EnableResourceNameDnsARecordOnLaunch bool
    Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false.
    EnableResourceNameDnsAaaaRecordOnLaunch bool
    Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false.
    Ipv6CidrBlock 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.
    MapCustomerOwnedIpOnLaunch bool
    Specify true to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. The customer_owned_ipv4_pool and outpost_arn arguments must be specified when set to true. Default is false.
    MapPublicIpOnLaunch bool
    Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is false.
    OutpostArn string
    The Amazon Resource Name (ARN) of the Outpost.
    PrivateDnsHostnameTypeOnLaunch string
    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.
    Tags 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.
    vpcId String
    The VPC ID.
    assignIpv6AddressOnCreation Boolean
    Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is false
    availabilityZone String
    AZ for the subnet.
    availabilityZoneId String
    AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use availability_zone instead.
    cidrBlock String
    The IPv4 CIDR block for the subnet.
    customerOwnedIpv4Pool String
    The customer owned IPv4 address pool. Typically used with the map_customer_owned_ip_on_launch argument. The outpost_arn argument must be specified when configured.
    enableDns64 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.
    enableLniAtDeviceIndex Integer
    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).
    enableResourceNameDnsARecordOnLaunch Boolean
    Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false.
    enableResourceNameDnsAaaaRecordOnLaunch Boolean
    Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false.
    ipv6CidrBlock 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.
    mapCustomerOwnedIpOnLaunch Boolean
    Specify true to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. The customer_owned_ipv4_pool and outpost_arn arguments must be specified when set to true. Default is false.
    mapPublicIpOnLaunch Boolean
    Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is false.
    outpostArn String
    The Amazon Resource Name (ARN) of the Outpost.
    privateDnsHostnameTypeOnLaunch String
    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.
    tags 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.
    vpcId string
    The VPC ID.
    assignIpv6AddressOnCreation boolean
    Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is false
    availabilityZone string
    AZ for the subnet.
    availabilityZoneId string
    AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use availability_zone instead.
    cidrBlock string
    The IPv4 CIDR block for the subnet.
    customerOwnedIpv4Pool string
    The customer owned IPv4 address pool. Typically used with the map_customer_owned_ip_on_launch argument. The outpost_arn argument must be specified when configured.
    enableDns64 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.
    enableLniAtDeviceIndex 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). A local network interface cannot be the primary network interface (eth0).
    enableResourceNameDnsARecordOnLaunch boolean
    Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false.
    enableResourceNameDnsAaaaRecordOnLaunch boolean
    Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false.
    ipv6CidrBlock 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.
    mapCustomerOwnedIpOnLaunch boolean
    Specify true to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. The customer_owned_ipv4_pool and outpost_arn arguments must be specified when set to true. Default is false.
    mapPublicIpOnLaunch boolean
    Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is false.
    outpostArn string
    The Amazon Resource Name (ARN) of the Outpost.
    privateDnsHostnameTypeOnLaunch string
    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.
    tags {[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_address_on_creation bool
    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_id str
    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_ipv4_pool str
    The customer owned IPv4 address pool. Typically used with the map_customer_owned_ip_on_launch argument. The outpost_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_at_device_index int
    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_name_dns_a_record_on_launch bool
    Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false.
    enable_resource_name_dns_aaaa_record_on_launch bool
    Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false.
    ipv6_cidr_block str
    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_owned_ip_on_launch bool
    Specify true to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. The customer_owned_ipv4_pool and outpost_arn arguments must be specified when set to true. Default is false.
    map_public_ip_on_launch bool
    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_hostname_type_on_launch str
    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.
    tags 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.
    vpcId String
    The VPC ID.
    assignIpv6AddressOnCreation Boolean
    Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is false
    availabilityZone String
    AZ for the subnet.
    availabilityZoneId String
    AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use availability_zone instead.
    cidrBlock String
    The IPv4 CIDR block for the subnet.
    customerOwnedIpv4Pool String
    The customer owned IPv4 address pool. Typically used with the map_customer_owned_ip_on_launch argument. The outpost_arn argument must be specified when configured.
    enableDns64 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.
    enableLniAtDeviceIndex 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). A local network interface cannot be the primary network interface (eth0).
    enableResourceNameDnsARecordOnLaunch Boolean
    Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false.
    enableResourceNameDnsAaaaRecordOnLaunch Boolean
    Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false.
    ipv6CidrBlock 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.
    mapCustomerOwnedIpOnLaunch Boolean
    Specify true to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. The customer_owned_ipv4_pool and outpost_arn arguments must be specified when set to true. Default is false.
    mapPublicIpOnLaunch Boolean
    Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is false.
    outpostArn String
    The Amazon Resource Name (ARN) of the Outpost.
    privateDnsHostnameTypeOnLaunch String
    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.
    tags 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.
    Ipv6CidrBlockAssociationId string
    The association ID for the IPv6 CIDR block.
    OwnerId string
    The ID of the AWS account that owns the subnet.
    TagsAll Dictionary<string, string>
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:Please use tags instead.

    Arn string
    The ARN of the subnet.
    Id string
    The provider-assigned unique ID for this managed resource.
    Ipv6CidrBlockAssociationId string
    The association ID for the IPv6 CIDR block.
    OwnerId string
    The ID of the AWS account that owns the subnet.
    TagsAll map[string]string
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:Please use tags instead.

    arn String
    The ARN of the subnet.
    id String
    The provider-assigned unique ID for this managed resource.
    ipv6CidrBlockAssociationId String
    The association ID for the IPv6 CIDR block.
    ownerId String
    The ID of the AWS account that owns the subnet.
    tagsAll Map<String,String>
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:Please use tags instead.

    arn string
    The ARN of the subnet.
    id string
    The provider-assigned unique ID for this managed resource.
    ipv6CidrBlockAssociationId string
    The association ID for the IPv6 CIDR block.
    ownerId string
    The ID of the AWS account that owns the subnet.
    tagsAll {[key: string]: string}
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:Please use tags instead.

    arn str
    The ARN of the subnet.
    id str
    The provider-assigned unique ID for this managed resource.
    ipv6_cidr_block_association_id str
    The association ID for the IPv6 CIDR block.
    owner_id str
    The ID of the AWS account that owns the subnet.
    tags_all Mapping[str, str]
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:Please use tags instead.

    arn String
    The ARN of the subnet.
    id String
    The provider-assigned unique ID for this managed resource.
    ipv6CidrBlockAssociationId String
    The association ID for the IPv6 CIDR block.
    ownerId String
    The ID of the AWS account that owns the subnet.
    tagsAll Map<String>
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:Please use tags instead.

    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.
    The following state arguments are supported:
    Arn string
    The ARN of the subnet.
    AssignIpv6AddressOnCreation bool
    Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is false
    AvailabilityZone string
    AZ for the subnet.
    AvailabilityZoneId string
    AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use availability_zone instead.
    CidrBlock string
    The IPv4 CIDR block for the subnet.
    CustomerOwnedIpv4Pool string
    The customer owned IPv4 address pool. Typically used with the map_customer_owned_ip_on_launch argument. The outpost_arn argument must be specified when configured.
    EnableDns64 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.
    EnableLniAtDeviceIndex int
    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).
    EnableResourceNameDnsARecordOnLaunch bool
    Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false.
    EnableResourceNameDnsAaaaRecordOnLaunch bool
    Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false.
    Ipv6CidrBlock string
    The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
    Ipv6CidrBlockAssociationId string
    The association ID for the IPv6 CIDR block.
    Ipv6Native bool
    Indicates whether to create an IPv6-only subnet. Default: false.
    MapCustomerOwnedIpOnLaunch bool
    Specify true to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. The customer_owned_ipv4_pool and outpost_arn arguments must be specified when set to true. Default is false.
    MapPublicIpOnLaunch bool
    Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is false.
    OutpostArn string
    The Amazon Resource Name (ARN) of the Outpost.
    OwnerId string
    The ID of the AWS account that owns the subnet.
    PrivateDnsHostnameTypeOnLaunch string
    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.
    Tags 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.
    TagsAll Dictionary<string, string>
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:Please use tags instead.

    VpcId string
    The VPC ID.
    Arn string
    The ARN of the subnet.
    AssignIpv6AddressOnCreation bool
    Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is false
    AvailabilityZone string
    AZ for the subnet.
    AvailabilityZoneId string
    AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use availability_zone instead.
    CidrBlock string
    The IPv4 CIDR block for the subnet.
    CustomerOwnedIpv4Pool string
    The customer owned IPv4 address pool. Typically used with the map_customer_owned_ip_on_launch argument. The outpost_arn argument must be specified when configured.
    EnableDns64 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.
    EnableLniAtDeviceIndex int
    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).
    EnableResourceNameDnsARecordOnLaunch bool
    Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false.
    EnableResourceNameDnsAaaaRecordOnLaunch bool
    Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false.
    Ipv6CidrBlock string
    The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
    Ipv6CidrBlockAssociationId string
    The association ID for the IPv6 CIDR block.
    Ipv6Native bool
    Indicates whether to create an IPv6-only subnet. Default: false.
    MapCustomerOwnedIpOnLaunch bool
    Specify true to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. The customer_owned_ipv4_pool and outpost_arn arguments must be specified when set to true. Default is false.
    MapPublicIpOnLaunch bool
    Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is false.
    OutpostArn string
    The Amazon Resource Name (ARN) of the Outpost.
    OwnerId string
    The ID of the AWS account that owns the subnet.
    PrivateDnsHostnameTypeOnLaunch string
    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.
    Tags 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.
    TagsAll map[string]string
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:Please use tags instead.

    VpcId string
    The VPC ID.
    arn String
    The ARN of the subnet.
    assignIpv6AddressOnCreation Boolean
    Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is false
    availabilityZone String
    AZ for the subnet.
    availabilityZoneId String
    AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use availability_zone instead.
    cidrBlock String
    The IPv4 CIDR block for the subnet.
    customerOwnedIpv4Pool String
    The customer owned IPv4 address pool. Typically used with the map_customer_owned_ip_on_launch argument. The outpost_arn argument must be specified when configured.
    enableDns64 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.
    enableLniAtDeviceIndex Integer
    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).
    enableResourceNameDnsARecordOnLaunch Boolean
    Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false.
    enableResourceNameDnsAaaaRecordOnLaunch Boolean
    Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false.
    ipv6CidrBlock String
    The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
    ipv6CidrBlockAssociationId String
    The association ID for the IPv6 CIDR block.
    ipv6Native Boolean
    Indicates whether to create an IPv6-only subnet. Default: false.
    mapCustomerOwnedIpOnLaunch Boolean
    Specify true to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. The customer_owned_ipv4_pool and outpost_arn arguments must be specified when set to true. Default is false.
    mapPublicIpOnLaunch Boolean
    Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is false.
    outpostArn String
    The Amazon Resource Name (ARN) of the Outpost.
    ownerId String
    The ID of the AWS account that owns the subnet.
    privateDnsHostnameTypeOnLaunch String
    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.
    tags 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.
    tagsAll Map<String,String>
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:Please use tags instead.

    vpcId String
    The VPC ID.
    arn string
    The ARN of the subnet.
    assignIpv6AddressOnCreation boolean
    Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is false
    availabilityZone string
    AZ for the subnet.
    availabilityZoneId string
    AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use availability_zone instead.
    cidrBlock string
    The IPv4 CIDR block for the subnet.
    customerOwnedIpv4Pool string
    The customer owned IPv4 address pool. Typically used with the map_customer_owned_ip_on_launch argument. The outpost_arn argument must be specified when configured.
    enableDns64 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.
    enableLniAtDeviceIndex 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). A local network interface cannot be the primary network interface (eth0).
    enableResourceNameDnsARecordOnLaunch boolean
    Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false.
    enableResourceNameDnsAaaaRecordOnLaunch boolean
    Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false.
    ipv6CidrBlock string
    The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
    ipv6CidrBlockAssociationId string
    The association ID for the IPv6 CIDR block.
    ipv6Native boolean
    Indicates whether to create an IPv6-only subnet. Default: false.
    mapCustomerOwnedIpOnLaunch boolean
    Specify true to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. The customer_owned_ipv4_pool and outpost_arn arguments must be specified when set to true. Default is false.
    mapPublicIpOnLaunch boolean
    Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is false.
    outpostArn string
    The Amazon Resource Name (ARN) of the Outpost.
    ownerId string
    The ID of the AWS account that owns the subnet.
    privateDnsHostnameTypeOnLaunch string
    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.
    tags {[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.
    tagsAll {[key: string]: string}
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:Please use tags instead.

    vpcId string
    The VPC ID.
    arn str
    The ARN of the subnet.
    assign_ipv6_address_on_creation bool
    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_id str
    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_ipv4_pool str
    The customer owned IPv4 address pool. Typically used with the map_customer_owned_ip_on_launch argument. The outpost_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_at_device_index int
    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_name_dns_a_record_on_launch bool
    Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false.
    enable_resource_name_dns_aaaa_record_on_launch bool
    Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false.
    ipv6_cidr_block str
    The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
    ipv6_cidr_block_association_id str
    The association ID for the IPv6 CIDR block.
    ipv6_native bool
    Indicates whether to create an IPv6-only subnet. Default: false.
    map_customer_owned_ip_on_launch bool
    Specify true to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. The customer_owned_ipv4_pool and outpost_arn arguments must be specified when set to true. Default is false.
    map_public_ip_on_launch bool
    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_hostname_type_on_launch str
    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.
    tags 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.
    tags_all Mapping[str, str]
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:Please use tags instead.

    vpc_id str
    The VPC ID.
    arn String
    The ARN of the subnet.
    assignIpv6AddressOnCreation Boolean
    Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. Default is false
    availabilityZone String
    AZ for the subnet.
    availabilityZoneId String
    AZ ID of the subnet. This argument is not supported in all regions or partitions. If necessary, use availability_zone instead.
    cidrBlock String
    The IPv4 CIDR block for the subnet.
    customerOwnedIpv4Pool String
    The customer owned IPv4 address pool. Typically used with the map_customer_owned_ip_on_launch argument. The outpost_arn argument must be specified when configured.
    enableDns64 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.
    enableLniAtDeviceIndex 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). A local network interface cannot be the primary network interface (eth0).
    enableResourceNameDnsARecordOnLaunch Boolean
    Indicates whether to respond to DNS queries for instance hostnames with DNS A records. Default: false.
    enableResourceNameDnsAaaaRecordOnLaunch Boolean
    Indicates whether to respond to DNS queries for instance hostnames with DNS AAAA records. Default: false.
    ipv6CidrBlock String
    The IPv6 network range for the subnet, in CIDR notation. The subnet size must use a /64 prefix length.
    ipv6CidrBlockAssociationId String
    The association ID for the IPv6 CIDR block.
    ipv6Native Boolean
    Indicates whether to create an IPv6-only subnet. Default: false.
    mapCustomerOwnedIpOnLaunch Boolean
    Specify true to indicate that network interfaces created in the subnet should be assigned a customer owned IP address. The customer_owned_ipv4_pool and outpost_arn arguments must be specified when set to true. Default is false.
    mapPublicIpOnLaunch Boolean
    Specify true to indicate that instances launched into the subnet should be assigned a public IP address. Default is false.
    outpostArn String
    The Amazon Resource Name (ARN) of the Outpost.
    ownerId String
    The ID of the AWS account that owns the subnet.
    privateDnsHostnameTypeOnLaunch String
    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.
    tags 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.
    tagsAll Map<String>
    A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

    Deprecated:Please use tags instead.

    vpcId String
    The VPC ID.

    Import

    Using pulumi import, import subnets using the subnet id. For example:

    $ 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.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.28.1 published on Thursday, Mar 28, 2024 by Pulumi