hashicorp / hashicorp/terraform-plugin-testing
Proposal: Enable plan checking support when migrating between schema versions
- Dominant language
- Go
- Stars
- 68
- Forks
- 22
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 1
Description
### terraform-plugin-testing version
```
github.com/hashicorp/terraform-plugin-testing v1.11.0
```
### Use cases
Testing provider enhancements that include schema changes is challenging with the current acceptance testing framework. If there are no schema changes, using `ExternalProviders` with a previous version and then a `PlanOnly` step works well.
However, this technique does not work when there are schema changes. Using `PlanOnly` will display changes that the user will see, but fail either with `The non-refresh plan was not empty` if there are changes, or a message such as `Error retrieving state, there may be dangling resources: exit status 1
Failed to marshal state to json: schema version 0 for aws_s3_bucket_lifecycle_configuration.test in state does not match version 1 from the provider` if there are no value changes.
Using `ConfigPlanChecks.PreApply` seems like it should work in this case. However, it does not show the changes between the existing state and the configured state, but instead _the existing state after the state upgrade has been run_ and the configured state.
### Proposal
Two possibilities:
1. If the underlying `terraform` calls can return the state without applying the state upgrader, the call used by `ConfigPlanChecks.PreApply` should be updated to use that
2. Otherwise, add a mechanism to collect state values similarly to how [`statecheck.CompareValue()`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing@v1.11.0/statecheck#CompareValue) works
Contributor guide
Assessment
This issue has not been assessed yet.