Developers wanting to write their own providers for infrastructure as code tool Terraform can now resort to a standalone Terraform Plugin SDK. Existing providers might need some light adapting, however.
For those not too familiar with this specific HashiCorp project, providers in Terraform are a type of plugin to expose services (such as AWS) and create, read, update, or delete connected resources (such as EC2 instances). Plugins run in separate processes and communicate with Terraform over an RPC interface.
The new Go module was carved out of the Terraform Core codebase, since the main elements were already present in the helper directory. It is designed to be compatible with all providers importing Terraform Core 0.12 and uses a gRPC wire protocol as an interface. Other plugin types – provisioners come to mind – aren’t supported by the SDK yet.
Before the extraction, devs new to provider creation had to figure out which parts of the core were relevant to them. The new structure could therefore help to lower the entry barrier, while also reducing the number of unnecessary dependencies.
It also allows the Terraform team to put out new SDK features and fixes in their own time and independently from the core releases. The now available first standalone release is fittingly presented as version 1.0 with all following updates adhering to the semantic versioning scheme.
Imports within providers might have to be slightly tweaked to keep working, since the SDK “aims to keep nearly 100 per cent backwards compatibility, aside from a handful of APIs”. To help with that, HashiCorp offers a migrator tool. It checks if the codebase can be migrated or has to be reworked first, looks at the use of Go modules, and informs devs should a provider use removed APIs.
Once this has been taken care of, the tool will rewrite the necessary elements to complete the move to the new SDK. Users preferring to go the manual route can do so by replacing references to github.com/hashicorp/terraform with github.com/hashicorp/terraform-plugin-sdk, although this isn’t really recommended.