hashicorp / terraform-plugin-go

A low-level Go binding for the Terraform protocol for integrations to be built on top of.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tfprotov6: Upgrade to Protocol Version 6.2

bflad opened this issue · comments

terraform-plugin-go version

v0.6.0

Use cases

Terraform Plugin Protocol versions 6.0 and 6.1 were missing the legacy_type_system field in the ApplyResourceChange.Response and PlanResourceChange.Response messages that was available in protocol version 5. This field is a special signal from terraform-plugin-sdk that switches certain consistency check errors into warning logs. More details about this handling can be found in hashicorp/terraform#30373 and hashicorp/terraform#20282.

The new protocol version with the legacy_type_system field has been merged and backported in Terraform CLI via hashicorp/terraform#30375

The reason this is important is that in the near future, terraform-plugin-mux will support logic to upgrade protocol version 5 servers to protocol version 6. The benefit is two-fold:

  • terraform-plugin-sdk/v2 (and tf5server, but arguably that is better to just convert to tf6server) could be upgraded to protocol version 6, to forcibly shed support for versions of Terraform CLI older than 1.0.
  • After that upgrade, terraform-plugin-sdk/v2 and terraform-plugin-framework servers can be muxed together, allowing existing sdk/v2 usage alongside new protocol features in framework (requiring Terraform CLI versions 1.0 and later). NOTE: It will also be possible to mux terraform-plugin-sdk/v2 and terraform-plugin-framework on protocol version 5 via an opposite downgrade; those servers just cannot use protocol version 6 functionality such as nested attributes.

Without the field present, upgrading terraform-plugin-sdk/v2 servers to protocol version 6 would be very problematic for provider maintainers.

Proposal

Standard procedure for protocol upgrades:

  • Copy the new protocol buffers file
  • Recompile the protocol buffers Go/gRPC code
  • Wire the "new" field through the tfprotov6 fromproto/toproto handling
  • Update the minor protocol version constant in tf6server

References