Hub

HomeBlog
Docs



DigitalOcean Provider

The CloudQuery DigitalOcean provider pulls configuration out of DigitalOcean resources, normalizes them and stores them in PostgreSQL database.

Install

cloudquery init digitalocean

Authentication

DigitalOcean API

To authenticate CloudQuery follow the authentication instructions in digitaloceans API reference

Spaces API

To create an access key for CloudQuery to read spaces api visit this Apps & API section of the DigitalOcean control panel for your account.

Configuration

The following configuration section can be automatically generated by cloudquery init digitalocean:

configuration { // API Token to access DigitalOcean resources // See https://docs.digitalocean.com/reference/api/api-reference/#section/Authentication // token = "<YOUR_API_TOKEN_HERE>" // List of regions to fetch spaces from, if not given all regions are assumed // spaces_regions = [] // Spaces Access Key generated at https://cloud.digitalocean.com/settings/api/tokens // spaces_access_key = "<YOUR_SPACES_ACCESS_KEY>" // Spaces Access Key Id generated at https://cloud.digitalocean.com/settings/api/tokens // spaces_access_key_id = "<YOUR_SPACES_ACCESS_KEY_ID>" }

Environment variables

The following environment variables can be used instead of passing in them in the configuration:

  1. DIGITALOCEAN_ACCESS_TOKEN & DIGITALOCEAN_TOKEN
  2. SPACES_ACCESS_KEY_ID & SPACES_SECRET_ACCESS_KEY

Query Examples

Find public facing spaces

-- public facing spaces are accessible by anyone, easily query which space is public facing in your account SELECT name, location, public, creation_date FROM digitalocean_spaces WHERE public = true;

List Droplets with public facing ipv4 or ipv6

-- Find any droplets that have a public ipv6 or ipv4 IP SELECT d.id as droplet_id, dnv4.ip_address as ip, dnv4.netmask, dnv4.gateway, dnv6.ip_address as ipv6, dnv6.netmask as ipv6_netmask, dnv6.gateway as ipv6_gateway from digitalocean_droplets d LEFT JOIN digitalocean_droplet_networks_v4 dnv4 ON d.cq_id = dnv4.droplet_cq_id LEFT JOIN digitalocean_droplet_networks_v6 dnv6 ON d.cq_id = dnv6.droplet_cq_id where dnv4.type = 'public' OR dnv6.type = 'public';

Billing History including current month balance

-- Get you current monthly balance and previous billing histories in one table SELECT invoice_id as id, description, amount, "date" FROM digitalocean_billing_history UNION SELECT'current' as id, 'current month balance' as description, month_to_date_usage as amount , generated_at as "date" FROM digitalocean_balance;
Version

v0.2.0

Repository
Published at

Mon Sep 13 2021

Resources
  • Blog

All Rights Reserved.
Terms of ServicePrivacy Policy