aws.ec2.DefaultVpc
Explore with Pulumi AI
Provides a resource to manage the default AWS VPC in the current AWS Region.
If you created your AWS account after 2013-12-04 you have a default VPC in each AWS 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.DefaultVpc resource behaves differently from normal resources in that if a default VPC exists, this provider does not create this resource, but instead “adopts” it into management.
If no default VPC exists, the provider creates a new default VPC, which leads to the implicit creation of other resources.
By default, pulumi destroy does not delete the default VPC but does remove the resource from the state.
Set the force_destroy argument to true to delete the default VPC.
Example Usage
Basic usage with tags:
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const _default = new aws.ec2.DefaultVpc("default", {tags: {
    Name: "Default VPC",
}});
import pulumi
import pulumi_aws as aws
default = aws.ec2.DefaultVpc("default", tags={
    "Name": "Default VPC",
})
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.NewDefaultVpc(ctx, "default", &ec2.DefaultVpcArgs{
			Tags: pulumi.StringMap{
				"Name": pulumi.String("Default VPC"),
			},
		})
		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 @default = new Aws.Ec2.DefaultVpc("default", new()
    {
        Tags = 
        {
            { "Name", "Default VPC" },
        },
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.DefaultVpc;
import com.pulumi.aws.ec2.DefaultVpcArgs;
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 default_ = new DefaultVpc("default", DefaultVpcArgs.builder()
            .tags(Map.of("Name", "Default VPC"))
            .build());
    }
}
resources:
  default:
    type: aws:ec2:DefaultVpc
    properties:
      tags:
        Name: Default VPC
Create DefaultVpc Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new DefaultVpc(name: string, args?: DefaultVpcArgs, opts?: CustomResourceOptions);@overload
def DefaultVpc(resource_name: str,
               args: Optional[DefaultVpcArgs] = None,
               opts: Optional[ResourceOptions] = None)
@overload
def DefaultVpc(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               assign_generated_ipv6_cidr_block: Optional[bool] = None,
               enable_dns_hostnames: Optional[bool] = None,
               enable_dns_support: Optional[bool] = None,
               enable_network_address_usage_metrics: Optional[bool] = None,
               force_destroy: Optional[bool] = None,
               ipv6_cidr_block: Optional[str] = None,
               ipv6_cidr_block_network_border_group: Optional[str] = None,
               ipv6_ipam_pool_id: Optional[str] = None,
               ipv6_netmask_length: Optional[int] = None,
               tags: Optional[Mapping[str, str]] = None)func NewDefaultVpc(ctx *Context, name string, args *DefaultVpcArgs, opts ...ResourceOption) (*DefaultVpc, error)public DefaultVpc(string name, DefaultVpcArgs? args = null, CustomResourceOptions? opts = null)
public DefaultVpc(String name, DefaultVpcArgs args)
public DefaultVpc(String name, DefaultVpcArgs args, CustomResourceOptions options)
type: aws:ec2:DefaultVpc
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args DefaultVpcArgs
- 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 DefaultVpcArgs
- 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 DefaultVpcArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DefaultVpcArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args DefaultVpcArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var defaultVpcResource = new Aws.Ec2.DefaultVpc("defaultVpcResource", new()
{
    AssignGeneratedIpv6CidrBlock = false,
    EnableDnsHostnames = false,
    EnableDnsSupport = false,
    EnableNetworkAddressUsageMetrics = false,
    ForceDestroy = false,
    Ipv6CidrBlock = "string",
    Ipv6CidrBlockNetworkBorderGroup = "string",
    Ipv6IpamPoolId = "string",
    Ipv6NetmaskLength = 0,
    Tags = 
    {
        { "string", "string" },
    },
});
example, err := ec2.NewDefaultVpc(ctx, "defaultVpcResource", &ec2.DefaultVpcArgs{
	AssignGeneratedIpv6CidrBlock:     pulumi.Bool(false),
	EnableDnsHostnames:               pulumi.Bool(false),
	EnableDnsSupport:                 pulumi.Bool(false),
	EnableNetworkAddressUsageMetrics: pulumi.Bool(false),
	ForceDestroy:                     pulumi.Bool(false),
	Ipv6CidrBlock:                    pulumi.String("string"),
	Ipv6CidrBlockNetworkBorderGroup:  pulumi.String("string"),
	Ipv6IpamPoolId:                   pulumi.String("string"),
	Ipv6NetmaskLength:                pulumi.Int(0),
	Tags: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
})
var defaultVpcResource = new DefaultVpc("defaultVpcResource", DefaultVpcArgs.builder()
    .assignGeneratedIpv6CidrBlock(false)
    .enableDnsHostnames(false)
    .enableDnsSupport(false)
    .enableNetworkAddressUsageMetrics(false)
    .forceDestroy(false)
    .ipv6CidrBlock("string")
    .ipv6CidrBlockNetworkBorderGroup("string")
    .ipv6IpamPoolId("string")
    .ipv6NetmaskLength(0)
    .tags(Map.of("string", "string"))
    .build());
default_vpc_resource = aws.ec2.DefaultVpc("defaultVpcResource",
    assign_generated_ipv6_cidr_block=False,
    enable_dns_hostnames=False,
    enable_dns_support=False,
    enable_network_address_usage_metrics=False,
    force_destroy=False,
    ipv6_cidr_block="string",
    ipv6_cidr_block_network_border_group="string",
    ipv6_ipam_pool_id="string",
    ipv6_netmask_length=0,
    tags={
        "string": "string",
    })
const defaultVpcResource = new aws.ec2.DefaultVpc("defaultVpcResource", {
    assignGeneratedIpv6CidrBlock: false,
    enableDnsHostnames: false,
    enableDnsSupport: false,
    enableNetworkAddressUsageMetrics: false,
    forceDestroy: false,
    ipv6CidrBlock: "string",
    ipv6CidrBlockNetworkBorderGroup: "string",
    ipv6IpamPoolId: "string",
    ipv6NetmaskLength: 0,
    tags: {
        string: "string",
    },
});
type: aws:ec2:DefaultVpc
properties:
    assignGeneratedIpv6CidrBlock: false
    enableDnsHostnames: false
    enableDnsSupport: false
    enableNetworkAddressUsageMetrics: false
    forceDestroy: false
    ipv6CidrBlock: string
    ipv6CidrBlockNetworkBorderGroup: string
    ipv6IpamPoolId: string
    ipv6NetmaskLength: 0
    tags:
        string: string
DefaultVpc Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The DefaultVpc resource accepts the following input properties:
- AssignGenerated boolIpv6Cidr Block 
- EnableDns boolHostnames 
- EnableDns boolSupport 
- EnableNetwork boolAddress Usage Metrics 
- ForceDestroy bool
- Whether destroying the resource deletes the default VPC. Default: false
- Ipv6CidrBlock string
- Ipv6CidrBlock stringNetwork Border Group 
- Ipv6IpamPool stringId 
- Ipv6NetmaskLength int
- Dictionary<string, string>
- AssignGenerated boolIpv6Cidr Block 
- EnableDns boolHostnames 
- EnableDns boolSupport 
- EnableNetwork boolAddress Usage Metrics 
- ForceDestroy bool
- Whether destroying the resource deletes the default VPC. Default: false
- Ipv6CidrBlock string
- Ipv6CidrBlock stringNetwork Border Group 
- Ipv6IpamPool stringId 
- Ipv6NetmaskLength int
- map[string]string
- assignGenerated BooleanIpv6Cidr Block 
- enableDns BooleanHostnames 
- enableDns BooleanSupport 
- enableNetwork BooleanAddress Usage Metrics 
- forceDestroy Boolean
- Whether destroying the resource deletes the default VPC. Default: false
- ipv6CidrBlock String
- ipv6CidrBlock StringNetwork Border Group 
- ipv6IpamPool StringId 
- ipv6NetmaskLength Integer
- Map<String,String>
- assignGenerated booleanIpv6Cidr Block 
- enableDns booleanHostnames 
- enableDns booleanSupport 
- enableNetwork booleanAddress Usage Metrics 
- forceDestroy boolean
- Whether destroying the resource deletes the default VPC. Default: false
- ipv6CidrBlock string
- ipv6CidrBlock stringNetwork Border Group 
- ipv6IpamPool stringId 
- ipv6NetmaskLength number
- {[key: string]: string}
- assign_generated_ boolipv6_ cidr_ block 
- enable_dns_ boolhostnames 
- enable_dns_ boolsupport 
- enable_network_ booladdress_ usage_ metrics 
- force_destroy bool
- Whether destroying the resource deletes the default VPC. Default: false
- ipv6_cidr_ strblock 
- ipv6_cidr_ strblock_ network_ border_ group 
- ipv6_ipam_ strpool_ id 
- ipv6_netmask_ intlength 
- Mapping[str, str]
- assignGenerated BooleanIpv6Cidr Block 
- enableDns BooleanHostnames 
- enableDns BooleanSupport 
- enableNetwork BooleanAddress Usage Metrics 
- forceDestroy Boolean
- Whether destroying the resource deletes the default VPC. Default: false
- ipv6CidrBlock String
- ipv6CidrBlock StringNetwork Border Group 
- ipv6IpamPool StringId 
- ipv6NetmaskLength Number
- Map<String>
Outputs
All input properties are implicitly available as output properties. Additionally, the DefaultVpc resource produces the following output properties:
- Arn string
- CidrBlock string
- The primary IPv4 CIDR block for the VPC
- DefaultNetwork stringAcl Id 
- DefaultRoute stringTable Id 
- DefaultSecurity stringGroup Id 
- DhcpOptions stringId 
- ExistingDefault boolVpc 
- Id string
- The provider-assigned unique ID for this managed resource.
- InstanceTenancy string
- The allowed tenancy of instances launched into the VPC
- Ipv6AssociationId string
- MainRoute stringTable Id 
- OwnerId string
- Dictionary<string, string>
- Arn string
- CidrBlock string
- The primary IPv4 CIDR block for the VPC
- DefaultNetwork stringAcl Id 
- DefaultRoute stringTable Id 
- DefaultSecurity stringGroup Id 
- DhcpOptions stringId 
- ExistingDefault boolVpc 
- Id string
- The provider-assigned unique ID for this managed resource.
- InstanceTenancy string
- The allowed tenancy of instances launched into the VPC
- Ipv6AssociationId string
- MainRoute stringTable Id 
- OwnerId string
- map[string]string
- arn String
- cidrBlock String
- The primary IPv4 CIDR block for the VPC
- defaultNetwork StringAcl Id 
- defaultRoute StringTable Id 
- defaultSecurity StringGroup Id 
- dhcpOptions StringId 
- existingDefault BooleanVpc 
- id String
- The provider-assigned unique ID for this managed resource.
- instanceTenancy String
- The allowed tenancy of instances launched into the VPC
- ipv6AssociationId String
- mainRoute StringTable Id 
- ownerId String
- Map<String,String>
- arn string
- cidrBlock string
- The primary IPv4 CIDR block for the VPC
- defaultNetwork stringAcl Id 
- defaultRoute stringTable Id 
- defaultSecurity stringGroup Id 
- dhcpOptions stringId 
- existingDefault booleanVpc 
- id string
- The provider-assigned unique ID for this managed resource.
- instanceTenancy string
- The allowed tenancy of instances launched into the VPC
- ipv6AssociationId string
- mainRoute stringTable Id 
- ownerId string
- {[key: string]: string}
- arn str
- cidr_block str
- The primary IPv4 CIDR block for the VPC
- default_network_ stracl_ id 
- default_route_ strtable_ id 
- default_security_ strgroup_ id 
- dhcp_options_ strid 
- existing_default_ boolvpc 
- id str
- The provider-assigned unique ID for this managed resource.
- instance_tenancy str
- The allowed tenancy of instances launched into the VPC
- ipv6_association_ strid 
- main_route_ strtable_ id 
- owner_id str
- Mapping[str, str]
- arn String
- cidrBlock String
- The primary IPv4 CIDR block for the VPC
- defaultNetwork StringAcl Id 
- defaultRoute StringTable Id 
- defaultSecurity StringGroup Id 
- dhcpOptions StringId 
- existingDefault BooleanVpc 
- id String
- The provider-assigned unique ID for this managed resource.
- instanceTenancy String
- The allowed tenancy of instances launched into the VPC
- ipv6AssociationId String
- mainRoute StringTable Id 
- ownerId String
- Map<String>
Look up Existing DefaultVpc Resource
Get an existing DefaultVpc 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?: DefaultVpcState, opts?: CustomResourceOptions): DefaultVpc@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        arn: Optional[str] = None,
        assign_generated_ipv6_cidr_block: Optional[bool] = None,
        cidr_block: Optional[str] = None,
        default_network_acl_id: Optional[str] = None,
        default_route_table_id: Optional[str] = None,
        default_security_group_id: Optional[str] = None,
        dhcp_options_id: Optional[str] = None,
        enable_dns_hostnames: Optional[bool] = None,
        enable_dns_support: Optional[bool] = None,
        enable_network_address_usage_metrics: Optional[bool] = None,
        existing_default_vpc: Optional[bool] = None,
        force_destroy: Optional[bool] = None,
        instance_tenancy: Optional[str] = None,
        ipv6_association_id: Optional[str] = None,
        ipv6_cidr_block: Optional[str] = None,
        ipv6_cidr_block_network_border_group: Optional[str] = None,
        ipv6_ipam_pool_id: Optional[str] = None,
        ipv6_netmask_length: Optional[int] = None,
        main_route_table_id: Optional[str] = None,
        owner_id: Optional[str] = None,
        tags: Optional[Mapping[str, str]] = None,
        tags_all: Optional[Mapping[str, str]] = None) -> DefaultVpcfunc GetDefaultVpc(ctx *Context, name string, id IDInput, state *DefaultVpcState, opts ...ResourceOption) (*DefaultVpc, error)public static DefaultVpc Get(string name, Input<string> id, DefaultVpcState? state, CustomResourceOptions? opts = null)public static DefaultVpc get(String name, Output<String> id, DefaultVpcState state, CustomResourceOptions options)resources:  _:    type: aws:ec2:DefaultVpc    get:      id: ${id}- 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
- AssignGenerated boolIpv6Cidr Block 
- CidrBlock string
- The primary IPv4 CIDR block for the VPC
- DefaultNetwork stringAcl Id 
- DefaultRoute stringTable Id 
- DefaultSecurity stringGroup Id 
- DhcpOptions stringId 
- EnableDns boolHostnames 
- EnableDns boolSupport 
- EnableNetwork boolAddress Usage Metrics 
- ExistingDefault boolVpc 
- ForceDestroy bool
- Whether destroying the resource deletes the default VPC. Default: false
- InstanceTenancy string
- The allowed tenancy of instances launched into the VPC
- Ipv6AssociationId string
- Ipv6CidrBlock string
- Ipv6CidrBlock stringNetwork Border Group 
- Ipv6IpamPool stringId 
- Ipv6NetmaskLength int
- MainRoute stringTable Id 
- OwnerId string
- Dictionary<string, string>
- Dictionary<string, string>
- Arn string
- AssignGenerated boolIpv6Cidr Block 
- CidrBlock string
- The primary IPv4 CIDR block for the VPC
- DefaultNetwork stringAcl Id 
- DefaultRoute stringTable Id 
- DefaultSecurity stringGroup Id 
- DhcpOptions stringId 
- EnableDns boolHostnames 
- EnableDns boolSupport 
- EnableNetwork boolAddress Usage Metrics 
- ExistingDefault boolVpc 
- ForceDestroy bool
- Whether destroying the resource deletes the default VPC. Default: false
- InstanceTenancy string
- The allowed tenancy of instances launched into the VPC
- Ipv6AssociationId string
- Ipv6CidrBlock string
- Ipv6CidrBlock stringNetwork Border Group 
- Ipv6IpamPool stringId 
- Ipv6NetmaskLength int
- MainRoute stringTable Id 
- OwnerId string
- map[string]string
- map[string]string
- arn String
- assignGenerated BooleanIpv6Cidr Block 
- cidrBlock String
- The primary IPv4 CIDR block for the VPC
- defaultNetwork StringAcl Id 
- defaultRoute StringTable Id 
- defaultSecurity StringGroup Id 
- dhcpOptions StringId 
- enableDns BooleanHostnames 
- enableDns BooleanSupport 
- enableNetwork BooleanAddress Usage Metrics 
- existingDefault BooleanVpc 
- forceDestroy Boolean
- Whether destroying the resource deletes the default VPC. Default: false
- instanceTenancy String
- The allowed tenancy of instances launched into the VPC
- ipv6AssociationId String
- ipv6CidrBlock String
- ipv6CidrBlock StringNetwork Border Group 
- ipv6IpamPool StringId 
- ipv6NetmaskLength Integer
- mainRoute StringTable Id 
- ownerId String
- Map<String,String>
- Map<String,String>
- arn string
- assignGenerated booleanIpv6Cidr Block 
- cidrBlock string
- The primary IPv4 CIDR block for the VPC
- defaultNetwork stringAcl Id 
- defaultRoute stringTable Id 
- defaultSecurity stringGroup Id 
- dhcpOptions stringId 
- enableDns booleanHostnames 
- enableDns booleanSupport 
- enableNetwork booleanAddress Usage Metrics 
- existingDefault booleanVpc 
- forceDestroy boolean
- Whether destroying the resource deletes the default VPC. Default: false
- instanceTenancy string
- The allowed tenancy of instances launched into the VPC
- ipv6AssociationId string
- ipv6CidrBlock string
- ipv6CidrBlock stringNetwork Border Group 
- ipv6IpamPool stringId 
- ipv6NetmaskLength number
- mainRoute stringTable Id 
- ownerId string
- {[key: string]: string}
- {[key: string]: string}
- arn str
- assign_generated_ boolipv6_ cidr_ block 
- cidr_block str
- The primary IPv4 CIDR block for the VPC
- default_network_ stracl_ id 
- default_route_ strtable_ id 
- default_security_ strgroup_ id 
- dhcp_options_ strid 
- enable_dns_ boolhostnames 
- enable_dns_ boolsupport 
- enable_network_ booladdress_ usage_ metrics 
- existing_default_ boolvpc 
- force_destroy bool
- Whether destroying the resource deletes the default VPC. Default: false
- instance_tenancy str
- The allowed tenancy of instances launched into the VPC
- ipv6_association_ strid 
- ipv6_cidr_ strblock 
- ipv6_cidr_ strblock_ network_ border_ group 
- ipv6_ipam_ strpool_ id 
- ipv6_netmask_ intlength 
- main_route_ strtable_ id 
- owner_id str
- Mapping[str, str]
- Mapping[str, str]
- arn String
- assignGenerated BooleanIpv6Cidr Block 
- cidrBlock String
- The primary IPv4 CIDR block for the VPC
- defaultNetwork StringAcl Id 
- defaultRoute StringTable Id 
- defaultSecurity StringGroup Id 
- dhcpOptions StringId 
- enableDns BooleanHostnames 
- enableDns BooleanSupport 
- enableNetwork BooleanAddress Usage Metrics 
- existingDefault BooleanVpc 
- forceDestroy Boolean
- Whether destroying the resource deletes the default VPC. Default: false
- instanceTenancy String
- The allowed tenancy of instances launched into the VPC
- ipv6AssociationId String
- ipv6CidrBlock String
- ipv6CidrBlock StringNetwork Border Group 
- ipv6IpamPool StringId 
- ipv6NetmaskLength Number
- mainRoute StringTable Id 
- ownerId String
- Map<String>
- Map<String>
Import
Using pulumi import, import Default VPCs using the VPC id. For example:
$ pulumi import aws:ec2/defaultVpc:DefaultVpc default vpc-a01106c2
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the awsTerraform Provider.