Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/healthcheck: Handle deletion outside of Terraform #787

Conversation

jacobbednarz
Copy link
Member

When a resource is managed by Terraform, any changes outside of the
configuration, should be synced to keep the state in sync. This
previously wasn't the case with healthchecks as the 404 error (here,
resource has been deleted outside of Terraform) was returning a generic
error for any non-success statuses. To fix this, we inspect the returned
error and check for a string which denotes the resource not longer
exists and then sets d.Id() to an empty string and Terraform handles
the lifecycle correctly.

Fixes #785

When a resource is managed by Terraform, any changes outside of the
configuration, should be synced to keep the state in sync. This
previously wasn't the case with healthchecks as the 404 error (here,
resource has been deleted outside of Terraform) was returning a generic
error for any non-success statuses. To fix this, we inspect the returned
error and check for a string which denotes the resource not longer
exists and then sets `d.Id()` to an empty string and Terraform handles
the lifecycle correctly.

Fixes cloudflare#785
@jacobbednarz jacobbednarz merged commit 5150d57 into cloudflare:master Sep 3, 2020
@jacobbednarz jacobbednarz deleted the handle-missing-remote-healthcheck-id branch September 3, 2020 22:06
boekkooi-lengoo pushed a commit to boekkooi-lengoo/terraform-provider-cloudflare that referenced this pull request Feb 28, 2022
Adds support for Magic Transit IPsec tunnels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Health Checks do not handle state changes outside of Terraform if removed
1 participant