steampipe plugin install twilio

Twilio + Steampipe

Twilio is a cloud communications platform, offering developers to programmatically make and receive phone calls, send and receive text messages, and perform other communication functions using its web service APIs.

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

List all active phone numbers in your Twilio account:

select
sid,
friendly_name,
extract(
day
from
now() - date_created
) as age,
account_sid
from
twilio_account_key;
+------------------------------------+---------------+-----+------------------------------------+
| sid | friendly_name | age | account_sid |
+------------------------------------+---------------+-----+------------------------------------+
| SK1dd43df2cc722a368ab925c0642d7896 | dev-test | 7 | ACe0ad3djf256b88c17e75fafd74ac483d |
| SK31fccd42e0071567e86fee58ed433600 | test-main | 7 | ACe0ad3djf256b88c17e75fafd74ac483d |
+------------------------------------+---------------+-----+------------------------------------+

Documentation

Get started

Install

Download and install the latest Twilio plugin:

steampipe plugin install twilio

Credentials

ItemDescription
Credentials1. Get your Account SID and Auth Token from Twilio Console.
2. If you want to use API keys to authenticate instead of your Twilio account SID and auth token, generate your API Keys.
RadiusEach connection represents a single Twilio account/sub-account.
Resolution1. Credentials explicitly set in a steampipe config file (~/.steampipe/config/twilio.spc).
2. Credentials specified in environment variables e.g. TWILIO_ACCOUNT_SID, TWILIO_API_KEY, TWILIO_API_SECRET, and TWILIO_AUTH_TOKEN.

Configuration

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

connection "twilio" {
plugin = "twilio"
# `account_sid` (Required) - The Account SID of your Twilio account/sub-account.
# If `account_sid` is not specified in a connection, it will be loaded from:
# The path specified in the `TWILIO_ACCOUNT_SID` environment variable.
# account_sid = "YOUR_ACCOUNT_SID"
# Authenticate using Authorization Token
# `auth_token` (optional) - The authorization token of your Twilio account/sub-account.
# If `auth_token` is not specified in a connection, it will be loaded from:
# The path specified in the `TWILIO_AUTH_TOKEN` environment variable.
# auth_token = "YOUR_AUTH_TOKEN"
# Authenticate using API Key and API Secret
# `api_key` (optional) - The API key.
# `api_secret` (optional) - The secret of your API key.
# If `api_key` and `api_secret` are not specified in a connection, it will be loaded from:
# The path specified in the `TWILIO_API_KEY` and `TWILIO_API_SECRET` environment variables.
# api_key = "YOUR_API_KEY"
# api_secret = "YOUR_API_SECRET"
}

Multi-Account Connections

You may create multiple twilio connections:

connection "twilio_01" {
plugin = "twilio"
auth_token = "YOUR_AUTH_TOKEN"
}
connection "twilio_02" {
plugin = "twilio"
api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"
}

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

select
*
from
twilio_02.twilio_account_call;

Alternatively, can use an unqualified name and it will be resolved according to the Search Path:

select
*
from
twilio_account_call;

You can 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 "twilio_all" {
plugin = "twilio"
type = "aggregator"
connections = ["twilio_01", "twilio_02"]
}

Querying tables from this connection will return results from the twilio_01 and twilio_02 connections:

select
*
from
twilio_all.twilio_account_call;

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

connection "twilio_all" {
type = "aggregator"
plugin = "twilio"
connections = ["twilio_*"]
}

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

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_twilio;
CREATE SERVER steampipe_twilio FOREIGN DATA WRAPPER steampipe_postgres_twilio OPTIONS (config '<your_config>');
CREATE SCHEMA twilio;
IMPORT FOREIGN SCHEMA twilio FROM SERVER steampipe_twilio INTO twilio;

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

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

$ sqlite3
sqlite> .load ./steampipe_sqlite_extension_twilio.so
sqlite> select steampipe_configure_twilio('<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)" -- twilio

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

steampipe_export_twilio --config '<your_config>' <table_name>