Skip to main content

firewalls

Creates, updates, deletes, gets or lists a firewalls resource.

Overview

Namefirewalls
TypeResource
Iddigitalocean.compute.firewalls

Fields

The following fields are returned by SELECT queries:

The response will be a JSON object with a firewall key. This will be set to an object containing the standard firewall attributes.

Firewalls responses will include only the resources that you are granted to see. Ensure that your API token includes all necessary <resource>:read permissions for requested firewall.

NameDatatypeDescription
idstringA unique ID that can be used to identify and reference a firewall. (example: bb4b2611-3d72-467b-8602-280330ecd65c)
namestringA human-readable name for a firewall. The name must begin with an alphanumeric character. Subsequent characters must either be alphanumeric characters, a period (.), or a dash (-). (pattern: ^[a-zA-Z0-9][a-zA-Z0-9.-]+$, example: firewall)
created_atstring (date-time)A time value given in ISO8601 combined date and time format that represents when the firewall was created. (example: 2020-05-23T21:24:00Z)
droplet_idsarrayAn array containing the IDs of the Droplets assigned to the firewall.

Requires droplet:read scope.
inbound_rulesarray
outbound_rulesarray
pending_changesarrayAn array of objects each containing the fields "droplet_id", "removing", and "status". It is provided to detail exactly which Droplets are having their security policies updated. When empty, all changes have been successfully applied.
statusstringA status string indicating the current state of the firewall. This can be "waiting", "succeeded", or "failed". (example: waiting)
tagsarrayA flat array of tag names as strings to be applied to the resource. Tag names must exist in order to be referenced in a request.

Requires tag:create and tag:read scopes.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
firewalls_getselectfirewall_idTo show information about an existing firewall, send a GET request to /v2/firewalls/$FIREWALL_ID.
firewalls_listselectper_page, pageTo list all of the firewalls available on your account, send a GET request to /v2/firewalls.
firewalls_createinsertdata__nameTo create a new firewall, send a POST request to /v2/firewalls. The request
must contain at least one inbound or outbound access rule.
firewalls_updatereplacefirewall_id, data__nameTo update the configuration of an existing firewall, send a PUT request to
/v2/firewalls/$FIREWALL_ID. The request should contain a full representation
of the firewall including existing attributes. Note that any attributes that
are not provided will be reset to their default values.



You must have read access (e.g. droplet:read) to all resources attached
to the firewall to successfully update the firewall.
firewalls_deletedeletefirewall_idTo delete a firewall send a DELETE request to /v2/firewalls/$FIREWALL_ID.

No response body will be sent back, but the response code will indicate
success. Specifically, the response code will be a 204, which means that the
action was successful with no returned body data.
firewalls_assign_dropletsexecfirewall_id, droplet_idsTo assign a Droplet to a firewall, send a POST request to
/v2/firewalls/$FIREWALL_ID/droplets. In the body of the request, there
should be a droplet_ids attribute containing a list of Droplet IDs.

No response body will be sent back, but the response code will indicate
success. Specifically, the response code will be a 204, which means that the
action was successful with no returned body data.
firewalls_delete_dropletsexecfirewall_id, droplet_idsTo remove a Droplet from a firewall, send a DELETE request to
/v2/firewalls/$FIREWALL_ID/droplets. In the body of the request, there should
be a droplet_ids attribute containing a list of Droplet IDs.

No response body will be sent back, but the response code will indicate
success. Specifically, the response code will be a 204, which means that the
action was successful with no returned body data.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
firewall_idstring (uuid)A unique ID that can be used to identify and reference a firewall. (example: bb4b2611-3d72-467b-8602-280330ecd65c)
pageintegerWhich 'page' of paginated results to return. (example: 1)
per_pageintegerNumber of items returned per page (example: 2)

SELECT examples

To show information about an existing firewall, send a GET request to /v2/firewalls/$FIREWALL_ID.

SELECT
id,
name,
created_at,
droplet_ids,
inbound_rules,
outbound_rules,
pending_changes,
status,
tags
FROM digitalocean.compute.firewalls
WHERE firewall_id = '{{ firewall_id }}' -- required;

INSERT examples

To create a new firewall, send a POST request to /v2/firewalls. The request
must contain at least one inbound or outbound access rule.

INSERT INTO digitalocean.compute.firewalls (
data__name,
data__droplet_ids,
data__tags,
data__inbound_rules,
data__outbound_rules
)
SELECT
'{{ name }}' --required,
'{{ droplet_ids }}',
'{{ tags }}',
'{{ inbound_rules }}',
'{{ outbound_rules }}'
RETURNING
firewall
;

REPLACE examples

To update the configuration of an existing firewall, send a PUT request to
/v2/firewalls/$FIREWALL_ID. The request should contain a full representation
of the firewall including existing attributes. Note that any attributes that
are not provided will be reset to their default values.



You must have read access (e.g. droplet:read) to all resources attached
to the firewall to successfully update the firewall.

REPLACE digitalocean.compute.firewalls
SET
data__name = '{{ name }}',
data__droplet_ids = '{{ droplet_ids }}',
data__tags = '{{ tags }}',
data__inbound_rules = '{{ inbound_rules }}',
data__outbound_rules = '{{ outbound_rules }}'
WHERE
firewall_id = '{{ firewall_id }}' --required
AND data__name = '{{ name }}' --required
RETURNING
firewall;

DELETE examples

To delete a firewall send a DELETE request to /v2/firewalls/$FIREWALL_ID.

No response body will be sent back, but the response code will indicate
success. Specifically, the response code will be a 204, which means that the
action was successful with no returned body data.

DELETE FROM digitalocean.compute.firewalls
WHERE firewall_id = '{{ firewall_id }}' --required;

Lifecycle Methods

To assign a Droplet to a firewall, send a POST request to
/v2/firewalls/$FIREWALL_ID/droplets. In the body of the request, there
should be a droplet_ids attribute containing a list of Droplet IDs.

No response body will be sent back, but the response code will indicate
success. Specifically, the response code will be a 204, which means that the
action was successful with no returned body data.

EXEC digitalocean.compute.firewalls.firewalls_assign_droplets 
@firewall_id='{{ firewall_id }}' --required
@@json=
'{
"droplet_ids": "{{ droplet_ids }}"
}';