AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.11.0 published on Wednesday, Aug 17, 2022 by Pulumi

DefaultSubnet

Provides a resource to manage a default subnet in the current region.

This is an advanced resource and has special caveats to be aware of when using it. Please read this document in its entirety before using this resource.

The aws.ec2.DefaultSubnet resource behaves differently from normal resources in that if a default subnet exists in the specified Availability Zone, this provider does not create this resource, but instead “adopts” it into management. If no default subnet exists, this provider creates a new default subnet. By default, pulumi destroy does not delete the default subnet but does remove the resource from the state. Set the force_destroy argument to true to delete the default subnet.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var defaultAz1 = new Aws.Ec2.DefaultSubnet("defaultAz1", new()
    {
        AvailabilityZone = "us-west-2a",
        Tags = 
        {
            { "Name", "Default subnet for us-west-2a" },
        },
    });

});
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.NewDefaultSubnet(ctx, "defaultAz1", &ec2.DefaultSubnetArgs{
			AvailabilityZone: pulumi.String("us-west-2a"),
			Tags: pulumi.StringMap{
				"Name": pulumi.String("Default subnet for us-west-2a"),
			},
		})
		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.DefaultSubnet;
import com.pulumi.aws.ec2.DefaultSubnetArgs;
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 defaultAz1 = new DefaultSubnet("defaultAz1", DefaultSubnetArgs.builder()        
            .availabilityZone("us-west-2a")
            .tags(Map.of("Name", "Default subnet for us-west-2a"))
            .build());

    }
}
import pulumi
import pulumi_aws as aws

default_az1 = aws.ec2.DefaultSubnet("defaultAz1",
    availability_zone="us-west-2a",
    tags={
        "Name": "Default subnet for us-west-2a",
    })
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const defaultAz1 = new aws.ec2.DefaultSubnet("default_az1", {
    availabilityZone: "us-west-2a",
    tags: {
        Name: "Default subnet for us-west-2a",
    },
});
resources:
  defaultAz1:
    type: aws:ec2:DefaultSubnet
    properties:
      availabilityZone: us-west-2a
      tags:
        Name: Default subnet for us-west-2a

Create a DefaultSubnet Resource

new DefaultSubnet(name: string, args: DefaultSubnetArgs, opts?: CustomResourceOptions);
@overload
def DefaultSubnet(resource_name: str,
                  opts: Optional[ResourceOptions] = None,
                  assign_ipv6_address_on_creation: Optional[bool] = None,
                  availability_zone: Optional[str] = None,
                  customer_owned_ipv4_pool: Optional[str] = None,
                  enable_dns64: Optional[bool] = None,
                  enable_resource_name_dns_a_record_on_launch: Optional[bool] = None,
                  enable_resource_name_dns_aaaa_record_on_launch: Optional[bool] = None,
                  force_destroy: 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,
                  private_dns_hostname_type_on_launch: Optional[str] = None,
                  tags: Optional[Mapping[str, str]] = None)
@overload
def DefaultSubnet(resource_name: str,
                  args: DefaultSubnetArgs,
                  opts: Optional[ResourceOptions] = None)
func NewDefaultSubnet(ctx *Context, name string, args DefaultSubnetArgs, opts ...ResourceOption) (*DefaultSubnet, error)
public DefaultSubnet(string name, DefaultSubnetArgs args, CustomResourceOptions? opts = null)
public DefaultSubnet(String name, DefaultSubnetArgs args)
public DefaultSubnet(String name, DefaultSubnetArgs args, CustomResourceOptions options)
type: aws:ec2:DefaultSubnet
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args DefaultSubnetArgs
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 DefaultSubnetArgs
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 DefaultSubnetArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args DefaultSubnetArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args DefaultSubnetArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

DefaultSubnet 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 DefaultSubnet resource accepts the following input properties:

AvailabilityZone string

is required

  • The availability_zone_id, cidr_block and vpc_id arguments become computed attributes
  • The default value for map_public_ip_on_launch is true
AssignIpv6AddressOnCreation bool
CustomerOwnedIpv4Pool string
EnableDns64 bool
EnableResourceNameDnsARecordOnLaunch bool
EnableResourceNameDnsAaaaRecordOnLaunch bool
ForceDestroy bool

Whether destroying the resource deletes the default subnet. Default: false

Ipv6CidrBlock string
Ipv6Native bool
MapCustomerOwnedIpOnLaunch bool
MapPublicIpOnLaunch bool
PrivateDnsHostnameTypeOnLaunch string
Tags Dictionary<string, string>
AvailabilityZone string

is required

  • The availability_zone_id, cidr_block and vpc_id arguments become computed attributes
  • The default value for map_public_ip_on_launch is true
AssignIpv6AddressOnCreation bool
CustomerOwnedIpv4Pool string
EnableDns64 bool
EnableResourceNameDnsARecordOnLaunch bool
EnableResourceNameDnsAaaaRecordOnLaunch bool
ForceDestroy bool

Whether destroying the resource deletes the default subnet. Default: false

Ipv6CidrBlock string
Ipv6Native bool
MapCustomerOwnedIpOnLaunch bool
MapPublicIpOnLaunch bool
PrivateDnsHostnameTypeOnLaunch string
Tags map[string]string
availabilityZone String

is required

  • The availability_zone_id, cidr_block and vpc_id arguments become computed attributes
  • The default value for map_public_ip_on_launch is true
assignIpv6AddressOnCreation Boolean
customerOwnedIpv4Pool String
enableDns64 Boolean
enableResourceNameDnsARecordOnLaunch Boolean
enableResourceNameDnsAaaaRecordOnLaunch Boolean
forceDestroy Boolean

Whether destroying the resource deletes the default subnet. Default: false

ipv6CidrBlock String
ipv6Native Boolean
mapCustomerOwnedIpOnLaunch Boolean
mapPublicIpOnLaunch Boolean
privateDnsHostnameTypeOnLaunch String
tags Map<String,String>
availabilityZone string

is required

  • The availability_zone_id, cidr_block and vpc_id arguments become computed attributes
  • The default value for map_public_ip_on_launch is true
assignIpv6AddressOnCreation boolean
customerOwnedIpv4Pool string
enableDns64 boolean
enableResourceNameDnsARecordOnLaunch boolean
enableResourceNameDnsAaaaRecordOnLaunch boolean
forceDestroy boolean

Whether destroying the resource deletes the default subnet. Default: false

ipv6CidrBlock string
ipv6Native boolean
mapCustomerOwnedIpOnLaunch boolean
mapPublicIpOnLaunch boolean
privateDnsHostnameTypeOnLaunch string
tags {[key: string]: string}
availability_zone str

is required

  • The availability_zone_id, cidr_block and vpc_id arguments become computed attributes
  • The default value for map_public_ip_on_launch is true
assign_ipv6_address_on_creation bool
customer_owned_ipv4_pool str
enable_dns64 bool
enable_resource_name_dns_a_record_on_launch bool
enable_resource_name_dns_aaaa_record_on_launch bool
force_destroy bool

Whether destroying the resource deletes the default subnet. Default: false

ipv6_cidr_block str
ipv6_native bool
map_customer_owned_ip_on_launch bool
map_public_ip_on_launch bool
private_dns_hostname_type_on_launch str
tags Mapping[str, str]
availabilityZone String

is required

  • The availability_zone_id, cidr_block and vpc_id arguments become computed attributes
  • The default value for map_public_ip_on_launch is true
assignIpv6AddressOnCreation Boolean
customerOwnedIpv4Pool String
enableDns64 Boolean
enableResourceNameDnsARecordOnLaunch Boolean
enableResourceNameDnsAaaaRecordOnLaunch Boolean
forceDestroy Boolean

Whether destroying the resource deletes the default subnet. Default: false

ipv6CidrBlock String
ipv6Native Boolean
mapCustomerOwnedIpOnLaunch Boolean
mapPublicIpOnLaunch Boolean
privateDnsHostnameTypeOnLaunch String
tags Map<String>

Outputs

All input properties are implicitly available as output properties. Additionally, the DefaultSubnet resource produces the following output properties:

Arn string
AvailabilityZoneId string

The AZ ID of the subnet

CidrBlock string

The IPv4 CIDR block assigned to the subnet

ExistingDefaultSubnet bool
Id string

The provider-assigned unique ID for this managed resource.

Ipv6CidrBlockAssociationId string
OutpostArn string
OwnerId string
TagsAll Dictionary<string, string>
VpcId string

The ID of the VPC the subnet is in

Arn string
AvailabilityZoneId string

The AZ ID of the subnet

CidrBlock string

The IPv4 CIDR block assigned to the subnet

ExistingDefaultSubnet bool
Id string

The provider-assigned unique ID for this managed resource.

Ipv6CidrBlockAssociationId string
OutpostArn string
OwnerId string
TagsAll map[string]string
VpcId string

The ID of the VPC the subnet is in

arn String
availabilityZoneId String

The AZ ID of the subnet

cidrBlock String

The IPv4 CIDR block assigned to the subnet

existingDefaultSubnet Boolean
id String

The provider-assigned unique ID for this managed resource.

ipv6CidrBlockAssociationId String
outpostArn String
ownerId String
tagsAll Map<String,String>
vpcId String

The ID of the VPC the subnet is in

arn string
availabilityZoneId string

The AZ ID of the subnet

cidrBlock string

The IPv4 CIDR block assigned to the subnet

existingDefaultSubnet boolean
id string

The provider-assigned unique ID for this managed resource.

ipv6CidrBlockAssociationId string
outpostArn string
ownerId string
tagsAll {[key: string]: string}
vpcId string

The ID of the VPC the subnet is in

arn str
availability_zone_id str

The AZ ID of the subnet

cidr_block str

The IPv4 CIDR block assigned to the subnet

existing_default_subnet bool
id str

The provider-assigned unique ID for this managed resource.

ipv6_cidr_block_association_id str
outpost_arn str
owner_id str
tags_all Mapping[str, str]
vpc_id str

The ID of the VPC the subnet is in

arn String
availabilityZoneId String

The AZ ID of the subnet

cidrBlock String

The IPv4 CIDR block assigned to the subnet

existingDefaultSubnet Boolean
id String

The provider-assigned unique ID for this managed resource.

ipv6CidrBlockAssociationId String
outpostArn String
ownerId String
tagsAll Map<String>
vpcId String

The ID of the VPC the subnet is in

Look up an Existing DefaultSubnet Resource

Get an existing DefaultSubnet 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?: DefaultSubnetState, opts?: CustomResourceOptions): DefaultSubnet
@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_resource_name_dns_a_record_on_launch: Optional[bool] = None,
        enable_resource_name_dns_aaaa_record_on_launch: Optional[bool] = None,
        existing_default_subnet: Optional[bool] = None,
        force_destroy: 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) -> DefaultSubnet
func GetDefaultSubnet(ctx *Context, name string, id IDInput, state *DefaultSubnetState, opts ...ResourceOption) (*DefaultSubnet, error)
public static DefaultSubnet Get(string name, Input<string> id, DefaultSubnetState? state, CustomResourceOptions? opts = null)
public static DefaultSubnet get(String name, Output<String> id, DefaultSubnetState 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
AssignIpv6AddressOnCreation bool
AvailabilityZone string

is required

  • The availability_zone_id, cidr_block and vpc_id arguments become computed attributes
  • The default value for map_public_ip_on_launch is true
AvailabilityZoneId string

The AZ ID of the subnet

CidrBlock string

The IPv4 CIDR block assigned to the subnet

CustomerOwnedIpv4Pool string
EnableDns64 bool
EnableResourceNameDnsARecordOnLaunch bool
EnableResourceNameDnsAaaaRecordOnLaunch bool
ExistingDefaultSubnet bool
ForceDestroy bool

Whether destroying the resource deletes the default subnet. Default: false

Ipv6CidrBlock string
Ipv6CidrBlockAssociationId string
Ipv6Native bool
MapCustomerOwnedIpOnLaunch bool
MapPublicIpOnLaunch bool
OutpostArn string
OwnerId string
PrivateDnsHostnameTypeOnLaunch string
Tags Dictionary<string, string>
TagsAll Dictionary<string, string>
VpcId string

The ID of the VPC the subnet is in

Arn string
AssignIpv6AddressOnCreation bool
AvailabilityZone string

is required

  • The availability_zone_id, cidr_block and vpc_id arguments become computed attributes
  • The default value for map_public_ip_on_launch is true
AvailabilityZoneId string

The AZ ID of the subnet

CidrBlock string

The IPv4 CIDR block assigned to the subnet

CustomerOwnedIpv4Pool string
EnableDns64 bool
EnableResourceNameDnsARecordOnLaunch bool
EnableResourceNameDnsAaaaRecordOnLaunch bool
ExistingDefaultSubnet bool
ForceDestroy bool

Whether destroying the resource deletes the default subnet. Default: false

Ipv6CidrBlock string
Ipv6CidrBlockAssociationId string
Ipv6Native bool
MapCustomerOwnedIpOnLaunch bool
MapPublicIpOnLaunch bool
OutpostArn string
OwnerId string
PrivateDnsHostnameTypeOnLaunch string
Tags map[string]string
TagsAll map[string]string
VpcId string

The ID of the VPC the subnet is in

arn String
assignIpv6AddressOnCreation Boolean
availabilityZone String

is required

  • The availability_zone_id, cidr_block and vpc_id arguments become computed attributes
  • The default value for map_public_ip_on_launch is true
availabilityZoneId String

The AZ ID of the subnet

cidrBlock String

The IPv4 CIDR block assigned to the subnet

customerOwnedIpv4Pool String
enableDns64 Boolean
enableResourceNameDnsARecordOnLaunch Boolean
enableResourceNameDnsAaaaRecordOnLaunch Boolean
existingDefaultSubnet Boolean
forceDestroy Boolean

Whether destroying the resource deletes the default subnet. Default: false

ipv6CidrBlock String
ipv6CidrBlockAssociationId String
ipv6Native Boolean
mapCustomerOwnedIpOnLaunch Boolean
mapPublicIpOnLaunch Boolean
outpostArn String
ownerId String
privateDnsHostnameTypeOnLaunch String
tags Map<String,String>
tagsAll Map<String,String>
vpcId String

The ID of the VPC the subnet is in

arn string
assignIpv6AddressOnCreation boolean
availabilityZone string

is required

  • The availability_zone_id, cidr_block and vpc_id arguments become computed attributes
  • The default value for map_public_ip_on_launch is true
availabilityZoneId string

The AZ ID of the subnet

cidrBlock string

The IPv4 CIDR block assigned to the subnet

customerOwnedIpv4Pool string
enableDns64 boolean
enableResourceNameDnsARecordOnLaunch boolean
enableResourceNameDnsAaaaRecordOnLaunch boolean
existingDefaultSubnet boolean
forceDestroy boolean

Whether destroying the resource deletes the default subnet. Default: false

ipv6CidrBlock string
ipv6CidrBlockAssociationId string
ipv6Native boolean
mapCustomerOwnedIpOnLaunch boolean
mapPublicIpOnLaunch boolean
outpostArn string
ownerId string
privateDnsHostnameTypeOnLaunch string
tags {[key: string]: string}
tagsAll {[key: string]: string}
vpcId string

The ID of the VPC the subnet is in

arn str
assign_ipv6_address_on_creation bool
availability_zone str

is required

  • The availability_zone_id, cidr_block and vpc_id arguments become computed attributes
  • The default value for map_public_ip_on_launch is true
availability_zone_id str

The AZ ID of the subnet

cidr_block str

The IPv4 CIDR block assigned to the subnet

customer_owned_ipv4_pool str
enable_dns64 bool
enable_resource_name_dns_a_record_on_launch bool
enable_resource_name_dns_aaaa_record_on_launch bool
existing_default_subnet bool
force_destroy bool

Whether destroying the resource deletes the default subnet. Default: false

ipv6_cidr_block str
ipv6_cidr_block_association_id str
ipv6_native bool
map_customer_owned_ip_on_launch bool
map_public_ip_on_launch bool
outpost_arn str
owner_id str
private_dns_hostname_type_on_launch str
tags Mapping[str, str]
tags_all Mapping[str, str]
vpc_id str

The ID of the VPC the subnet is in

arn String
assignIpv6AddressOnCreation Boolean
availabilityZone String

is required

  • The availability_zone_id, cidr_block and vpc_id arguments become computed attributes
  • The default value for map_public_ip_on_launch is true
availabilityZoneId String

The AZ ID of the subnet

cidrBlock String

The IPv4 CIDR block assigned to the subnet

customerOwnedIpv4Pool String
enableDns64 Boolean
enableResourceNameDnsARecordOnLaunch Boolean
enableResourceNameDnsAaaaRecordOnLaunch Boolean
existingDefaultSubnet Boolean
forceDestroy Boolean

Whether destroying the resource deletes the default subnet. Default: false

ipv6CidrBlock String
ipv6CidrBlockAssociationId String
ipv6Native Boolean
mapCustomerOwnedIpOnLaunch Boolean
mapPublicIpOnLaunch Boolean
outpostArn String
ownerId String
privateDnsHostnameTypeOnLaunch String
tags Map<String>
tagsAll Map<String>
vpcId String

The ID of the VPC the subnet is in

Import

Subnets can be imported using the subnet id, e.g.,

 $ pulumi import aws:ec2/defaultSubnet:DefaultSubnet public_subnet subnet-9d4a7b6c

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.