# state-file-fixer

Utility to fix Terraform state in certain upgrade scenarios.

## Provider Configuration Not Present

This error occurs when upgrading a module where the module previously defined a provider inside the module, which has subsequently been removed, and resources are being destroyed as part of the upgrade.

Examples:

* Updating terraform-lambda from <=2.4.0 to >=2.4.1
* Updating terraform-datadog from <=3.4.0 to >=4.0.0

The Jenkinsfile provides a mechanism to automatically update the state to reference providers defined at the root of a project, for dev/prod environments within terraform-infra.

To run this locally:

* Copy `.env.shadow` to `.env`
* Set `TERRAFORM_PROJECT` and `GITHUB_SSH_KEY_FILE` as required
* Run the following:

```
docker compose run --rm --build hoist-providers
```
