Problem
When the plan phase of a Destroy run completes, the run is errored and the last line of the plan output is:
Failed running command "cd '/terraform' && envdir /env terraform show -json /terraform/terraform.tfplan" (exit 1)
Output: Failed to marshal plan to json: error marshaling prior state: unsupported attribute "<some_attribute>"
Prerequisites
- Terraform Enterprise v202308-1 or older(legacy)
Cause
terraform show
is run at Plan phase of every Run to create data used by other services such as Sentinel and Cost Estimation. When there's mismatch of provider version between the prior state and current provider specified in configuration file, above error could be thrown due to changes in resource schema of later provider version.
Solution
Update the state to newest schema prior to Destroy Run. Possible solutions are:
- Start a new Refresh-only plan. Refresh-only support is available in Terraform Enterprise
v202106-1
or later and requires a workspace using at least Terraform CLIv0.15.4
. - Update the config with no-op change, e.g.
null_resource
,Apply
a new Run successfully - Update Terraform config to provider version used for existing state file
Outcome
The Destroy Run should complete successfully. If the issue persists, please reach out to HashiCorp support for additional assistance.