Skip to content

Resource: awsDefaultVpc

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 awsDefaultVpc resource behaves differently from normal resources in that if a default VPC exists, Terraform does not create this resource, but instead "adopts" it into management. If no default VPC exists, Terraform creates a new default VPC, which leads to the implicit creation of other resources. By default, terraformDestroy does not delete the default VPC but does remove the resource from Terraform state. Set the forceDestroy argument to true to delete the default VPC.

Example Usage

Basic usage with tags:

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.defaultVpc.DefaultVpc(this, "default", {
  tags: {
    Name: "Default VPC",
  },
});

Argument Reference

The arguments of an awsDefaultVpc differ slightly from those of awsVpc:

  • The cidrBlock and instanceTenancy arguments become computed attributes
  • The default value for enableDnsHostnames is true

The following additional arguments are supported:

  • forceDestroy - (Optional) Whether destroying the resource deletes the default VPC. Default: false

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • cidrBlock - The primary IPv4 CIDR block for the VPC
  • instanceTenancy - The allowed tenancy of instances launched into the VPC

Import

Default VPCs can be imported using the vpcId, e.g.,

$ terraform import aws_default_vpc.default vpc-a01106c2