This tool generates a Terraform provider from an OpenAPI specification and a configuration file.
- Python 3.6+
- Go 1.16+
- Terraform 1.0+
- GoReleaser (optional, for building and releasing the provider)
- jinja2 (Python package)
- pyyaml (Python package)
- Install required Python package:
pip install terraform-ittfit openapi-spec.yaml config.yaml --output-dir ./terraform-provider-<provider_name>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)
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 SDKAfter 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>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