Skip to content

Provider does not tolerate destruction of resources outside of Terraform #366

@erikeckhardt

Description

@erikeckhardt

Problem

In Terraform, if a resource that was created by Terraform and exists in the state file does NOT exist inside the cloud environment, providers are supposed to treat that as a CREATE operation instead of erroring out like so:

Error: elastic: Error 404 (Not Found): [my-es-domain-snapshots] missing [type=repository_missing_exception]

Even deleting the resources from my .tf source code (leaving the provider block in place) did not work, and that should have been treated as a NO-OP.

Solution

Tolerate resources not being present that are listed in the state file.

Specific example: if a repository can't be found, don't blow up. Just create the repository again (or do nothing if the resource is not in the .tf source).

Rationale

Mistakes happen. Cloud resources can be deleted. After such a deletion today for me in a non-prouction environment, the provider throwing this error meant I had to do tfstate surgery to remove the resources myself, and I also had to update the DynamoDb md5 fingerprint entry to match the new hash of the state file. These would be very painful in a production environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions