steampipe plugin install hcloudsteampipe plugin install hcloud

Hetzner Cloud + Steampipe

Hetzner Cloud is a cloud hosting located in Germany.

Steampipe is an open-source zero-ETL engine to instantly query cloud APIs using SQL.

List servers in your Hetzner Cloud account:

select
id,
name,
created
from
hcloud_server
+----------+-------------------+---------------------+
| id | name | created |
+----------+-------------------+---------------------+
| 14462596 | ubuntu-2gb-hel1-1 | 2021-09-18 01:53:27 |
+----------+-------------------+---------------------+

Documentation

Get started

Install

Download and install the latest Hetzner Cloud plugin:

steampipe plugin install hcloud

Configuration

Installing the latest hcloud plugin will create a config file (~/.steampipe/config/hcloud.spc) with a single connection named hcloud:

connection "hcloud" {
plugin = "hcloud"
token = "RCgLZcAGBBGqkr8lTFXCfLhCjLMM6OJtzhg4ZsDRdMvmUwAeLssvLWyCCTdV8lkB"
}
  • token - API token from Hetzner Cloud.

Multi-Account Connections

You may create multiple hcloud connections:

connection "hcloud_dev" {
plugin = "hcloud"
token = "RCgLZcAGBBGqkr8lTFXCfLhCjNNY6OJtzhg4ZsDRdMvmUwAeLssvLWyRRRdV8lkB"
}
connection "hcloud_qa" {
plugin = "hcloud"
token = "RCgLZcAGBBGqkr8lTFXCfLhCjNNY6OJtzhg4ZsDRdMvmUwAeLzzrLWyRRRdV8lkB"
}
connection "hcloud_prod" {
plugin = "hcloud"
token = "RCgLZcAGBBGqkr8lTFXCfLhCjNNY6OJtzhg4ZsDRdMvmUwAeLmmyLWyRRRdV8lkB"
}

Each connection is implemented as a distinct Postgres schema. As such, you can use qualified table names to query a specific connection:

select
*
from
hcloud_qa.hcloud_volume

You can create multi-account connections by using an aggregator connection. Aggregators allow you to query data from multiple connections for a plugin as if they are a single connection.

connection "hcloud_all" {
plugin = "hcloud"
type = "aggregator"
connections = ["hcloud_dev", "hcloud_qa", "hcloud_prod"]
}

Querying tables from this connection will return results from the hcloud_dev, hcloud_qa, and hcloud_prod connections:

select
*
from
hcloud_all.hcloud_volume

Alternatively, you can use an unqualified name and it will be resolved according to the Search Path. It's a good idea to name your aggregator first alphabetically so that it is the first connection in the search path (i.e. hcloud_all comes before hcloud_dev):

select
*
from
hcloud_volume

Steampipe supports the * wildcard in the connection names. For example, to aggregate all the hcloud plugin connections whose names begin with hcloud_:

connection "hcloud_all" {
type = "aggregator"
plugin = "hcloud"
connections = ["hcloud_*"]
}

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)" -- hcloud

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_hcloud;
CREATE SERVER steampipe_hcloud FOREIGN DATA WRAPPER steampipe_postgres_hcloud OPTIONS (config '<your_config>');
CREATE SCHEMA hcloud;
IMPORT FOREIGN SCHEMA hcloud FROM SERVER steampipe_hcloud INTO hcloud;

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)" -- hcloud

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_hcloud function to configure it with plugin-specific options.

$ sqlite3
sqlite> .load ./steampipe_sqlite_extension_hcloud.so
sqlite> select steampipe_configure_hcloud('<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)" -- hcloud

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

steampipe_export_hcloud --config '<your_config>' <table_name>