GithubHelp home page GithubHelp logo

isabella232 / pulumi-terraform-bridge Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pulumi/pulumi-terraform-bridge

0.0 0.0 0.0 3.56 MB

A library allowing providers built with the Terraform Plugin SDK to be bridged into Pulumi.

License: Apache License 2.0

Shell 0.12% Go 99.30% Makefile 0.58% HCL 0.01%

pulumi-terraform-bridge's Introduction

Build Status Go Report Card GoDoc

Pulumi Terraform Bridge

This bridge adapts any Terraform Provider built using the Terraform Plugin SDK 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 [email protected]:pulumi/pulumi-terraform-bridge $GOPATH/src/github.com/pulumi/pulumi-terraform-bridge
$ cd $GOPATH/src/github.com/pulumi/pulumi-terraform-bridge

Before building, you will need to ensure dependencies have been downloaded into the vendor/ directory.

$ make 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 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.

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 of the sdk, and then add the requisite directives to the provider file. See the AWS overlays section in resources.go for an example of this in action.

tfgen options

tfgen, the command that generates Pulumi schema/code for a bridged provider supports the following environment variables:

  • PULUMI_MISSING_MAPPING_ERROR: If truthy, fail if a data source or resource in the TF provider is not mapped to the Pulumi provider.
  • PULUMI_MISSING_DOCS_ERROR: If truthy, fail if docs cannot be found for a data source or resource.
  • PULUMI_EXTRA_MAPPING_ERROR: If truthy, fail if a mapped data source or resource does not exist in the TF provider.

pulumi-terraform-bridge's People

Contributors

benesch avatar cyrusnajmabadi avatar dmelo avatar dustinfarris avatar ekrengel avatar ellismg avatar evanboyle avatar frassle avatar guineveresaenger avatar hausdorff avatar iwahbe avatar jaxxstorm avatar jen20 avatar jetvova avatar jkodroff avatar joeduffy avatar justinvp avatar khyperia avatar komalali avatar lblackstone avatar lukehoban avatar mikhailshilkov avatar mmdriley avatar pgavlin avatar praneetloke avatar stack72 avatar subhabh avatar swgillespie avatar t-vova avatar t0yv0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.