-
Notifications
You must be signed in to change notification settings - Fork 17
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:
- If the underlying
terraformcalls can return the state without applying the state upgrader, the call used byConfigPlanChecks.PreApplyshould be updated to use that - Otherwise, add a mechanism to collect state values similarly to how
statecheck.CompareValue()works