How to Destroy a VPC

A Virtual Private Cloud (VPC) is a private network interface for collections of DigitalOcean resources. VPC networks are inaccessible from the public internet and other VPC networks, and traffic on them doesn’t count against bandwidth usage. You can link VPC networks to each other using VPC peering connections.


Deleting a VPC network permanently and irreversibly destroys the network.

You can only destroy a VPC network that has no resources in it. You can either destroy the resources or safely migrate Droplets, volumes, and databases out of a VPC network first.

Delete a VPC Network Using Automation

How to Delete a VPC Network Using the DigitalOcean CLI
  1. Install doctl, the DigitalOcean command-line tool.

  2. Create a personal access token and save it for use with doctl.

  3. Use the token to grant doctl access to your DigitalOcean account.

              doctl auth init
              
  4. Finally, run doctl vpcs delete. Basic usage looks like this, but you can read the usage docs for more details:

                doctl vpcs delete <vpc-id> [flags]
              

    The following example deletes the VPC network with the ID f81d4fae-7dec-11d0-a765-00a0c91e6bf6:

                  doctl vpcs delete f81d4fae-7dec-11d0-a765-00a0c91e6bf6
                
How to Delete a VPC Network Using the DigitalOcean API
  1. Create a personal access token and save it for use with the API.

  2. Send a DELETE request to https://api.digitalocean.com/v2/vpcs/{vpc_id}

    cURL

    Using cURL:

                    curl -X DELETE \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
      "https://api.digitalocean.com/v2/vpcs/e0fe0f4d-596a-465e-a902-571ce57b79fa"
                  

    Go

    Using Godo, the official DigitalOcean V2 API client for Go:

                    import (
        "context"
        "os"
    
        "github.com/digitalocean/godo"
    )
    
    func main() {
        token := os.Getenv("DIGITALOCEAN_TOKEN")
    
        client := godo.NewFromToken(token)
        ctx := context.TODO()
    
        resp, err := client.VPCs.Delete(ctx, "5a4981aa-9653-4bd1-bef5-d6bff52042e4")
    }
                  

    Python

                    import os
    from pydo import Client
    
    client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
    
    resp = client.vpcs.delete(vpc_id="e0fe0f4d")
                  

Delete a VPC Network Using the Control Panel

To destroy a VPC network, click Networking in the main menu, then click the VPC tab. In the VPC Networks tab, click the More menu of the VPC network you want to destroy and select Edit Settings.

Edit settings

In the VPC network’s Settings tab, click Destroy VPC. In the confirmation window, click Confirm to destroy the VPC network.

Confirm destroy