Translating Protocol Version 5 to 6
The tf5to6server
package enables translating a protocol version 5 provider server into a protocol version 6 provider server.
Use this package to:
- Migrate individual resources and data sources from terraform-plugin-sdk/v2 to terraform-plugin-framework over time, while using protocol version 6 features in terraform-plugin-framework.
- Develop with terraform-plugin-sdk/v2, but require Terraform CLI 1.0 or later.
Compatibility
Protocol version 6 provider servers are compatible with Terraform CLI 1.0 and later. Terraform CLI 1.1.5 and later is required to upgrade terraform-plugin-sdk/v2.
The following provider server implementations are supported:
- terraform-plugin-sdk/v2: A higher-level SDK that makes Terraform provider development easier by abstracting implementation details.
- terraform-plugin-go tf5server: A lower-level SDK to develop Terraform providers for more advanced use cases.
Requirements
Upgrading provider servers from protocol version 5 to protocol version 6 has no provider code requirements.
If publishing to the Terraform Registry, set metadata.protocol_versions
to ["6.0"]
in the Terraform Registry manifest file.
Code Implementation
Use the tf5to6server.UpgradeServer()
function to wrap a provider server. For most providers, this is either in the provider main()
function of the root directory main.go
file or where tf6muxserver
is implemented in the codebase.
The following example upgrades a terraform-plugin-sdk/v2 provider.
The following example uses tf6server
to serve the upgraded provider directly.
The following example uses tf6muxserver
to serve the upgraded provider while it is combined with others.
Refer to the tf6muxserver
documentation for more details about how to serve the combined provider.
Testing Implementation
You can test the original provider using the same acceptance tests as before. Set the ProtoV6ProviderFactories
field of TestCase
with an instance of the upgraded server, instead of declaring the provider with other TestCase
fields such as ProviderFactories
.
The following example creates a test for a combined provider.
Refer to the acceptance tests documentation for more details.