brandonc / tfpgen

Experimental, exploratory, do not use

Home Page:https://brandoncroft.com/notes/tfpgen

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tfpgen

An experimental OpenAPI → Terraform Provider generator that does not yet function. The goal is to allow developers to incrementally generate and maintain their own simple Terraform Provider using an OpenAPI 3 specification.

  • Examine an OpenAPI spec, identify RESTful resource groups tfpgen examine spec.yaml
  • Generate a config file for each discovered resource/data source tfpgen init spec.yaml
  • Using a combination of the spec and config, generate the provider tfpgen generate
    • Generate Terraform plugin framework code for each resource/datasource
    • Generate http client code and caller code for each resource/datasource
    • Generate Terraform framework provider code to describe resource schema
    • Generate acceptance tests

Other Solutions

  • terraform-provider-openapi A single provider that configures itself at runtime given an OpenAPI specification. This is incredibly cool. However, in the author's opinion, given that the underlying state AND the specification can drift away from the stored Terraform state, operating this provider can give unpredictable results.

  • terraform-provider-restapi Manage a RESTful resource as a terraform resource. Another neat approach, but it requires that you define the API as Terraform config. The state of the object is completely dependent on the raw response of the endpoint.

Usage

tfpgen [--version] [--help] <command> [<args>]

Available commands are:

command description
examine Examine an openapi 3 specification and display a list of possible data sources and resources
init Create an initial configuration based on a spec. This file is meant to be edited in order to compose a provider
generate Generate Terraform provider using the configuration

Try it:

go run main.go examine examples/openapi3/petstore.yaml

About

Experimental, exploratory, do not use

https://brandoncroft.com/notes/tfpgen


Languages

Language:Go 99.8%Language:Makefile 0.2%