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
- 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 fileconfig.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:
- Copy the built provider to your Terraform plugins directory
- Create a Terraform configuration file that uses the provider
- Run
terraform initto initialize the provider - Run
terraform planandterraform applyto use the provider
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file terraform_it-0.1.3.tar.gz.
File metadata
- Download URL: terraform_it-0.1.3.tar.gz
- Upload date:
- Size: 21.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0447a504d17fbf0bcb0f26a1262ce23be8775595a20d7d4eb9ede4aab9652c2b
|
|
| MD5 |
23259484fbefe22ed0126a959662463f
|
|
| BLAKE2b-256 |
3ec101bfa890ec5d95b867e65c052818246c9a9005845dcd1d422b2441309c04
|
File details
Details for the file terraform_it-0.1.3-py3-none-any.whl.
File metadata
- Download URL: terraform_it-0.1.3-py3-none-any.whl
- Upload date:
- Size: 35.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a506e9262e2cee5908e1d372f8edf8713f9eebd159ea8e69b8916ff49ab35dc
|
|
| MD5 |
bc4556d45e3202e336413bb4189c4620
|
|
| BLAKE2b-256 |
914514fbb16d7adb09042d969751e8d7f7744b835bcbdc7cb0bf2b1af502a2a8
|