Skip to main content

A Pulumi package for consuming Terraform Remote State resources.

Project description

Build Status

Pulumi Terraform Bridge

This bridge adapts any Terraform Provider for use with Pulumi. The Terraform community provides resource providers that perform create, read, update, and delete (CRUD) operations for a broad array of infrastructure providers and types. In principle, any of them can be programmed using Pulumi with this bridge.

If you want to wrap a new Terraform provider as a Pulumi provider, check out pulumi/pulumi-tf-provider-boilerplate.

Overview

Although the Terraform schema is used as a starting point, the concept of “overlays” enables customization, including classification into modules, stronger typing, better documentation, and more. Pulumi can also augment providers with non-CRUD operations like queries, metrics, and logs – while not having to repeat all of the considerable and quality work that has already gone into building reliable CRUD operations against the major cloud providers’ platforms.

Most users of Pulumi don’t need to know how this bridge works. Many will find it interesting, and, if you’d like to bring up a new provider that is available in Terraform but not yet Pulumi, we would love to hear from you.

How It Works

There are two major things involved in this bridge: design-time and runtime.

At design-time, we code-generate packages by dynamic inspection of a Terraform Provider’s schema. This only works for providers that are built using static schemas. It is possible to write Terraform Providers without this, which means the ability to create packages would not exist, but in practice all interesting providers use it.

Second, the bridge connects the Pulumi engine to a given Terraform Provider using Pulumi’s RPC interfaces. This behavior also leverages the Terraform provider schema, for operations like performing validation and diffs.

Development

This section only matters if you want to build this bridge from scratch, or use it in your own project.

Prerequisites

Before doing any development, there are a few prerequisites to install:

Building and Testing

There is a Makefile in the root that builds and tests everything.

To build, ensure $GOPATH is set, and clone into a standard Go workspace:

$ git clone git@github.com:pulumi/pulumi-terraform $GOPATH/src/github.com/pulumi/pulumi-terraform
$ cd $GOPATH/src/github.com/pulumi/pulumi-terraform

Before building, you will need to ensure dependencies have been restored to your enlistment:

$ dep ensure

At this point you can run make to build and run tests:

$ make

This repo on its own isn’t particularly interesting, until it is used to create a new Pulumi provider.

Adapting a New Terraform Provider

It is relatively easy to adapt a Terraform Provider, X, for use with Pulumi. The AWS provider offers a good blueprint for how to go about this.

You will create two Go binaries – one purely for design-time usage to act as X’s code-generator and the other for runtime usage to serve as its dynamic resource plugin – and link with the Terraform Provider repo and this one. There is then typically a resources.go file that maps all of the Terraform Provider metadata available at runtime to types and concepts that the bridge will use to generate well-typed programmatic abstractions.

The AWS provider provides a standard blueprint to follow for this. There are three major elements:

The `Makefile <https://github.com/pulumi/pulumi-aws/blob/master/Makefile>`__ compiles these programs, and notably, uses the resulting pulumi-tfgen-aws binary to generate code for many different languages. The resulting generated code is stored in the `sdk directory <https://github.com/pulumi/pulumi-aws/tree/master/sdk>`__.

Augmenting Auto-Generated Code w/ Overlays

An overlay is a set of additional directives that the code generator obeys when creating the final packages.

These may specify additional types, functions, or entire modules in this directory may be merged into the resulting package. This can be useful for helper modules and functions, in addition to gradual typing, such as using strongly typed enums in places where the underlying provider may only have weakly typed strings.

To do this, first add the files in the appropriate package sub-directory, and then add the requisite directives to the provider file. See the AWS overlays directory for an example of this in action.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pulumi_terraform-0.18.4.dev1568410757.tar.gz (14.0 kB view details)

Uploaded Source

File details

Details for the file pulumi_terraform-0.18.4.dev1568410757.tar.gz.

File metadata

  • Download URL: pulumi_terraform-0.18.4.dev1568410757.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.7

File hashes

Hashes for pulumi_terraform-0.18.4.dev1568410757.tar.gz
Algorithm Hash digest
SHA256 34773aa893c51d783aed07ce089bc9ba819534c9ffe52d2eb662f326dc5add91
MD5 578433cee881a9a9dc10a6cf69ce0385
BLAKE2b-256 a15330d82ce3ba228cbb569b4e0c09f3e00339d34cb2395534f8a1149c8088bd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page