steampipe-plugin-tfbridge

command module
v0.0.0-...-dbb8265 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2024 License: MPL-2.0 Imports: 2 Imported by: 0

README

image

Terraform Bridge Plugin for Steampipe

Use SQL to query data from the datasources of any Terraform provider.

This repo contains a Steampipe plugin that lets the user call any (?) data source that is exposed by a Terraform provider. This will expand the reach of Steampipe's plugins to also cover remote APIs that have a Terraform provider but no Steampipe plugin. This will also let users unify efforts: the Terraform provider can be used to manage resources, and querying on the current state of those resources can be done via Steampipe, using the same source code and provider.

Quick start

Install the plugin with Steampipe:

steampipe plugin install jreyesr/tfbridge

Configure your config file to point to a Terraform provider+version. If the Terraform provider requires configuration values, provide them too.

Run steampipe:

steampipe query

Run a query for whatever data source the Terraform provider exposes:

select
  attr1,
  attr2
from
  datasource_name;

Developing

Prerequisites:

Clone:

git clone https://github.com/jreyesr/steampipe-plugin-tfbridge.git
cd steampipe-plugin-tfbridge

Build, which automatically installs the new version to your ~/.steampipe/plugins directory:

make

Configure the plugin:

cp config/* ~/.steampipe/config
vi ~/.steampipe/config/tfbridge.spc

Try it!

steampipe query
> .inspect tfbridge

Further reading:

Contributing

Please see the contribution guidelines and our code of conduct. All contributions are subject to the Mozilla Public License 2.0 open source license.

Old proof of concept

Previously (see the poc tag), the repo only contained a proof of concept Go program that was used to test ways of driving a Terraform plugin. This wasn't too documented before, with Terraform's docs merely stating that

For projects that actually want to drive the provider, the supported option is to use the gRPC protocol and the RPC calls the protocol supplies. This protocol is the same protocol that drives Terraform's CLI interface, and it is versioned using a protocol version.

However, no widely-known projects that I could find did so (i.e., the only major consumer of Terraform providers is the Terraform project itself).

This series of posts contains much more information, discussions, pictures, screenshots of tests, comparisons with other tools, and more. Of particular interest may be the first (oldest) 3 posts, since they deal with driving Terraform providers outside of Terraform. Further posts cover the development of a Steampipe plugin, so they may be of less interest if you wish to drive Terraform providers yourself.

The main.go.old file implements a subset of Terraform's functionality as it pertains to providers: it spawns a provider, connects to it via gRPC over a Unix domain socket, and then it issues RPCs to the provider.

  • GetProviderSchema retrieves the provider's schema (which configuration values it requires, which data sources it exposes, and the fields and data types of each data source)
  • ConfigureProvider provides a set of configuration values to the provider
  • ReadDataSource retrieves some data from one of the provider's data sources

More information about the RPCs that every provider implements (since Terraform the CLI uses them) can be found here.

The main.go.old file contains a bunch of code that performs the RPCs on two Terraform plugins, DNS and Terraform Enterprise. Commented code was used before to test oter functionality or other use cases. You may use the file (and all the associated directories) as a starting point to develop your own consumers of Terraform providers.

Licensing

This repo vendors some internal code from the Terraform project, since that can't be reused via the standard Go import system. Those files are MPL 2.0 and © HashiCorp, Inc. The following directories contain those files:

  • configschema
  • logging
  • plugin
  • providers
  • tfdiags
  • tfplugin5

While ChooseALicense seems to state that "a larger work using the licensed work may be distributed under different terms", I'm licensing the entire plugin under MPL 2.0 to be sure.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL