Terraform provider code generation is an extensible solution that lets developers automate portions of their provider development workflow — now in tech preview.
Today, we are excited to announce a tech preview of HashiCorp Terraform provider code generation, consisting of a suite of tools that generate Terraform provider code from an OpenAPI specification. Included in this preview is a provider code specification that lets developers extend code generation to work with their own tooling and development practices.
Providers are executable binaries written in the Go language that act as a bridge between Terraform and an API service. Terraform’s ecosystem currently has more than 3,600 providers in the public registry, of which a majority of the code has been manually developed.
Bridging between API services and Terraform provider code is often repetitive across resources and operations. This repetitive maintenance can result in code consistency issues such as schema definitions missing attributes and validation, or data mapping that has invalid conversions between types.
Provider maintainers have managed these issues with shared code, linting tools, and in some cases, specialized code generation. Code generation can reduce maintenance burden, as well as create more consistency in the codebase. However, existing provider code generation tooling tends to be very specialized to individual providers.
The HashiCorp Terraform provider code generation tech preview introduces a scalable code generation ecosystem based on a shared specification that can be extended by the existing provider developer community. HashiCorp is offering three general-purpose solutions to bootstrap the ecosystem that can be used together or independently.
If your Terraform provider interacts with an API service that is documented with an OpenAPI specification, you could use all of the available tools to generate provider code, as shown here:
However, if your API service uses a different interface definition language (IDL), such as Protobuf, you may prefer to build your own provider spec generator specific to your API, then use the available framework code generator, as shown here:
To learn more about the code generation tools and the overall solution design, please refer to the code generation documentation. You can get a hands-on understanding of the new tools in the code generation tools tutorial and workflow example.
Please share any bugs, enhancement requests, or questions with us via the Terraform discussion forum. We look forward to your feedback and want to thank you for being such a great community!
If you are completely new to Terraform, sign up for Terraform Cloud and get started using the Free offering today.
Improve the developer experience writing Terraform code with the help of generative AI powered by Amazon CodeWhisperer.
HashiCorp’s Terraform provider for AWS now enables users to manage their S3 Express buckets.
A new view in the HashiCorp Terraform extension for Visual Studio Code shows your Terraform Cloud workspaces and runs, reducing context-switching.