doctl-databases-firewalls
Manage DigitalOcean database cluster firewalls
TLDR
Run a doctl databases firewalls command with an access token
Retrieve a list of firewall rules for a given database
Add a database firewall rule to a given database
Remove a firewall rule for a given database
SYNOPSIS
doctl databases firewalls <command> [<flags>]
Common subcommands include:
doctl databases firewalls list <database-id>
doctl databases firewalls add-rule <database-id> <flags>
doctl databases firewalls remove-rule <database-id> <flags>
doctl databases firewalls create <database-id> <flags>
doctl databases firewalls delete <database-id>
doctl databases firewalls get <database-id>
PARAMETERS
list
Retrieves and displays all currently configured firewall rules for a specified database cluster.
add-rule
Adds a new inbound firewall rule to a database cluster's existing firewall configuration. This rule specifies a permitted source (IP, CIDR, Droplet, or Kubernetes cluster).
remove-rule
Deletes an existing inbound firewall rule from a database cluster's firewall configuration based on its value and type.
create
Initializes and applies a new firewall configuration to a database cluster, optionally including an initial set of rules.
delete
Removes the entire firewall configuration for a specified database cluster, making it accessible from all IPs (unless other network restrictions are in place).
get
Fetches and displays detailed information about the firewall configuration of a database cluster, including all its associated rules.
DESCRIPTION
The doctl databases firewalls command group is an integral part of the DigitalOcean command-line interface (doctl), providing comprehensive control over network access to your managed database clusters.
This command set allows users to configure and manage inbound firewall rules for various database engines, including PostgreSQL, MySQL, Redis, and MongoDB.
It enables specifying which IP addresses, IP ranges (CIDR), DigitalOcean Droplets, or Kubernetes clusters are permitted to establish connections to your database instances.
By utilizing these commands, users can secure their databases by enforcing network isolation and preventing unauthorized access, which is crucial for maintaining data security and compliance.
The streamlined terminal-based management facilitates automation, scripting, and integration into CI/CD pipelines for robust infrastructure-as-code practices.
CAVEATS
1. doctl Installation and Configuration: Requires the doctl CLI tool to be installed and properly configured with a valid DigitalOcean API token.
2. Database ID Requirement: Most operations necessitate the unique identifier (UUID) of the target database cluster. This ID can be obtained via doctl databases list.
3. Rule Specificity: Firewall rules are highly specific. Ensure correct IP addresses, CIDR ranges, Droplet IDs, or Kubernetes URNs are provided to avoid connectivity issues.
4. Ingress Control Only: These firewalls control inbound network traffic to the database. They do not manage outbound connections from the database.
5. Impact of Deletion: Deleting a database firewall (using delete) typically makes the database publicly accessible from any IP address unless other network-level security measures are active.
<I>PERMISSIONS AND API TOKEN SCOPE</I>
To manage database firewalls, your DigitalOcean API token must have appropriate read/write permissions for database resources. Tokens with more restrictive scopes might not be able to perform all operations.
<I>SECURITY BEST PRACTICES</I>
Always adhere to the principle of least privilege when configuring firewall rules. Only allow access from known and necessary sources to minimize the attack surface and enhance database security. Regularly review and update your firewall rules.
HISTORY
The development of the doctl command-line interface closely mirrors the expansion of DigitalOcean's cloud offerings. As DigitalOcean introduced and matured its managed database services, the need for programmatic interaction became paramount.
The doctl databases firewalls command group was integrated into the CLI to empower users to manage database security settings directly from their terminal.
This evolution aligns with the industry trend towards infrastructure-as-code and automation, enabling developers and operations teams to embed database security configurations into their automated deployment and management workflows, significantly enhancing operational efficiency and security posture.
SEE ALSO
doctl databases(1): For general management and listing of DigitalOcean managed database clusters., doctl compute firewall(1): For managing network firewalls specifically for DigitalOcean Droplets and other compute resources.