turbot/cloudflare
steampipe plugin install cloudflare

Cloudflare + Steampipe

Query your Cloudflare infrastructure including zones, DNS records, accounts and more.

Installation

Download and install the latest Cloudflare plugin:

steampipe plugin install cloudflare

Configuration

Connection configurations are defined using HCL in one or more Steampipe config files. Steampipe will load ALL configuration files from ~/.steampipe/config that have a .spc extension. A config file may contain multiple connections.

Installing the latest cloudflare plugin will create a connection file (~/.steampipe/config/cloudflare.spc) with a single connection named cloudflare. You must modify this connection to include your personal credentials.

An API Token is the recommended way to set credentials. Read scope is required (write is not):

connection "cloudflare" {
plugin = "cloudflare"
token = "psth3GX0qHavRYE-hd5y7_iL7piII6C8jR3FOuW3"
}

It's also valid to use an email and API key:

connection "cloudflare" {
plugin = "cloudflare"
email = "pam@dundermifflin.com"
api_key = "2980b99351d629a537f1440e12b5b97a135b7"
}

Credentials are resolved in this order:

  1. token in Steampipe config.
  2. email and api_key in Steampipe config.
  3. CLOUDFLARE_API_TOKEN environment variable (like Terraform).
  4. CLOUDFLARE_EMAIL and CLOUDFLARE_API_KEY environment variables (like Terraform).
  5. CF_API_TOKEN environment variable (like flarectl).
  6. CF_API_EMAIL and CF_API_KEY environment variables (like flarectl).

For example:

connection "cloudflare" {
plugin = "cloudflare"
token = "9wZVRX3j9Z1CiE38HcmThwkb2hThisIsAFakeToken"
}

Configuring R2 API credentials

In order to access the R2 APIs, you must Generate an S3 Auth token to serve as the Access Key for usage with existing S3-compatible SDKs.

connection "cloudflare" {
plugin = "cloudflare"
access_key = "YOUR_R2_ACCESS_KEY_ID"
secret_key = "YOUR_R2_SECRET_ACCESS_KEY"
}

Scope

A Cloudflare connection is scoped to a single Cloudflare account, with a single set of credentials.

Postgres FDW

This plugin is available as a native Postgres FDW. Unlike Steampipe CLI, which ships with an embedded Postgres server instance, the Postgres FDW can be installed in any supported Postgres database version.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_postgres_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/postgres.sh)" -- cloudflare

The installer will prompt you for the plugin name and version, download and install the appropriate files for your OS, system architecture, and Postgres version.

To configure the Postgres FDW, you will create an extension, foreign server, and schema and import the foreign schema.

CREATE EXTENSION IF NOT EXISTS steampipe_postgres_cloudflare;
CREATE SERVER steampipe_cloudflare FOREIGN DATA WRAPPER steampipe_postgres_cloudflare OPTIONS (config '<your_config>');
CREATE SCHEMA cloudflare;
IMPORT FOREIGN SCHEMA cloudflare FROM SERVER steampipe_cloudflare INTO cloudflare;

SQLite Extension

This plugin is available as a SQLite Extension, making the tables available as SQLite virtual tables.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_sqlite_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/sqlite.sh)" -- cloudflare

The installer will prompt you for the plugin name, version, and destination directory. It will then determine the OS and system architecture, and it will download and install the appropriate package.

To configure the SQLite extension, load the extension module and then run the steampipe_configure_cloudflare function to configure it with plugin-specific options.

$ sqlite3
sqlite> .load ./steampipe_sqlite_extension_cloudflare.so
sqlite> select steampipe_configure_cloudflare('<your_config>');

Export

This plugin is available as a standalone Export CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- cloudflare

You can pass the configuration to the command with the --config argument:

steampipe_export_cloudflare --config '<your_config>' <table_name>