Skip to main content

A tool to generate Terraform providers from OpenAPI specs and Go SDKs.

Project description

Terraform Provider Generator

This tool generates a Terraform provider from an OpenAPI specification and a configuration file.

Prerequisites

  • Python 3.6+
  • Go 1.16+
  • Terraform 1.0+
  • GoReleaser (optional, for building and releasing the provider)
  • jinja2 (Python package)
  • pyyaml (Python package)

Installation

  1. Install required Python package:
pip install terraform-it

Usage

tfit openapi-spec.yaml config.yaml --output-dir ./terraform-provider-rivet

Arguments

  • openapi_spec.yml: Path to the OpenAPI specification YAML file
  • config.yml: Path to the configuration YAML file that defines resources and data sources
  • --output-dir: (Optional) Output directory for generated files (default: current directory)

Configuration File Format

The configuration file (config.yml) should define resources and data sources in the following format:

sdk-client-path: SDKClientPath
resources:
  ResourceName:
    resource-path: ResourcePath in SDK
    read:
      method: get
      name: FunctionName in SDK
      path: /path/to/resource/{id}
    create:
      method: post
      name: FunctionName in SDK
      path: /path/to/resource
    update:
      method: put
      name: FunctionName in SDK
      path: /path/to/resource/{id}
    delete:
      method: delete
      name: FunctionName in SDK
      path: /path/to/resource/{id}

datasources:
  DatasourceName:
    read: /path/to/resource/{id}
    list: /path/to/resources
    list-name: FunctionName in SDK

Building the Provider

After generating the provider code, check the CHECK.md file for any manual changes or additions required. Then you can build it with:

cd <output_directory>
go build -o terraform-provider-<provider_name>

Using the Provider

To use the provider in Terraform:

  1. Copy the built provider to your Terraform plugins directory
  2. Create a Terraform configuration file that uses the provider
  3. Run terraform init to initialize the provider
  4. Run terraform plan and terraform apply to use the provider

Project details


Download files

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

Source Distribution

terraform_it-0.1.5.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

terraform_it-0.1.5-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file terraform_it-0.1.5.tar.gz.

File metadata

  • Download URL: terraform_it-0.1.5.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for terraform_it-0.1.5.tar.gz
Algorithm Hash digest
SHA256 9b86cd6c8879eeb32edf14bac135bc7a58e559a158da58e36a5745ee95f05d80
MD5 0aeb183c07e90695216f1d1b1b496e7e
BLAKE2b-256 ab5f3e79379d3bc3db3d22b690f0d72a25d5f7ec34b9dc1c4ac3a12f3c2721a6

See more details on using hashes here.

File details

Details for the file terraform_it-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: terraform_it-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 35.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for terraform_it-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ff80e815a783fc6e672bc355801c411d0b680c98d5c209b212fa0f61c41bc4ff
MD5 809494bf182eec170cbf865a18bf7bd3
BLAKE2b-256 7b95de6b788e2a45a3067aad50ed3eb2cca1b567511abca7a6c67a0bd9e3ba03

See more details on using hashes here.

Supported by

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