Do data sources support state migrations?

See this question on StackOverflow for a full list of details:

Hi @reimoosejaw,

Data resources do not require state migrations. They are read-only resources, so the action of reading them updates the state to the latest version. For this reason, Terraform does not call the UpgradeResourceState method for data sources.

I’m not sure what is going on the legacy SDK when using StateUpgraders on a data source, the error looks like it might be from json decoding? That may be something they can prevent in the schema validation.

I’m encountering the same issue after upgrading the Kustomization provider I maintain to SDK v2. Is there a proposed solution for provider maintainers?

The issue is a result of a schema change that v2 required. In v1 the previous schema was valid.

For my understanding @jbardin, when you say legacy SDK, does that include v2?

I’ve filed an SDK issue with information how to reproduce the error: Terraform plan/refresh error caused by existing data source state after schema change · Issue #929 · hashicorp/terraform-plugin-sdk · GitHub

This has been fixed in the latest Terraform CLI 1.1.x and 1.2.x (currently alpha) versions.