kelvintaywl / terraform-provider-circleci

(Unofficial) Terraform Provider for CircleCI
https://registry.terraform.io/providers/kelvintaywl/circleci/latest
Mozilla Public License 2.0
12 stars 3 forks source link

Destroying resource should not raise error if resource no longer found #31

Closed kelvintaywl closed 1 year ago

kelvintaywl commented 1 year ago

Right now, the provider raises an error if the underlying resource is already deleted / not found (i.e, the API returns HTTP 404).

│ Error: Encountered error reading Project(github/[redacted]) checkout key [redacted]
│ 
│   with circleci_checkout_key.test[184],
│   on resource.tf line 6, in resource "circleci_checkout_key" "test":
│    6: resource "circleci_checkout_key" "test" {
│ 
│ response status code does not match any response statuses defined for this
│ endpoint in the swagger spec (status 404): {}

We should make the provider skip without bubbling the error if the resource is already deleted or no longer found. This would follow Hashicorp's recommendation: https://developer.hashicorp.com/terraform/plugin/framework/resources/delete#recommendations

To accomplish this, we would want to:

kelvintaywl commented 1 year ago

(1) is done via github.com/kelvintaywl/circleci-go-sdk@v0.2.5 (See https://github.com/kelvintaywl/circleci-go-sdk/commit/e8d165cf933afa4f2f184a8c03a9de5e1d2eba9f)