Destroy a Firewall Using the CLI
The destroy command requires the firewall’s ID to be destroyed. To retrieve a list of firewalls and their IDs, use the doctl compute firewall list
command.
How to Destroy a Firewall Using the DigitalOcean CLI
- Install
doctl
, the official DigitalOcean CLI.
- Create a personal access token and save it for use with
doctl
.
- Use the token to grant
doctl
access to your DigitalOcean account.
- Finally, run
doctl compute firewall delete
. Basic usage looks like this, but you can read the usage docs for more details:
doctl compute firewall delete <firewall-id>... [flags]
The following example deletes a cloud firewall with the ID f81d4fae-7dec-11d0-a765-00a0c91e6bf6
:
doctl compute firewall delete f81d4fae-7dec-11d0-a765-00a0c91e6bf6
Destroy a Firewall Using the API
The destroy call requires the firewall’s ID to be destroyed. To retrieve a list of firewalls and their IDs, use the /v2/firewalls
firewalls endpoint.
How to Destroy a Firewall Using the DigitalOcean API
- Create a personal access token and save it for use with the API.
- Send a DELETE request to
https://api.digitalocean.com/v2/firewalls/{firewall_id}
.
cURL
Using cURL:
curl -X DELETE \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
"https://api.digitalocean.com/v2/firewalls/bb4b2611-3d72-467b-8602-280330ecd65c"
Go
Using Godo, the official DigitalOcean 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()
_, err := client.Firewalls.Delete(ctx, 'bb4b2611-3d72-467b-8602-280330ecd65c')
}
Ruby
Using DropletKit, the official DigitalOcean API client for Ruby:
require 'droplet_kit'
token = ENV['DIGITALOCEAN_TOKEN']
client = DropletKit::Client.new(access_token: token)
client.firewalls.delete(id: 'bb4b2611-3d72-467b-8602-280330ecd65c')
Python
Using PyDo, the official DigitalOcean API client for Python:
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
resp = client.firewalls.delete(firewall_id= "as9di9d")
Destroy a Firewall Using the Control Panel
To destroy a firewall, from the Networking section of the control panel, click the Firewalls tab. Open the More menu of the firewall you want to destroy and click Destroy.
In the Destroy Firewall window that opens, click Confirm to destroy the firewall. Destroying a firewall does not destroy the Droplets that were associated with it.