fastly / terraform-provider-fastly

Terraform Fastly provider
https://www.terraform.io/docs/providers/fastly/
Mozilla Public License 2.0
119 stars 140 forks source link

Ordering issue when deleting config store linked to compute service #876

Open joeshaw opened 3 months ago

joeshaw commented 3 months ago

Terraform Version

Terraform v1.6.4 via Terraform Enterprise

Affected Fastly Terraform Resource(s)

Please list the affected resources, for example:

Expected Behavior

I have a compute service which has a resource link to a config store. In a tf update, I am unlinking the store and deleting it. I expect that the service would be updated first to remove the link, then the config store would be deleted.

Actual Behavior

The config store is attempted to be deleted first, and errors because there is an existing link to a service.

I think the issue is a lack of an implicit dependency between the service and the resource.

Steps to Reproduce

  1. Create a config store resource (not sure if this also applies to KV or secret stores)
  2. Add some entries to the config store
  3. Create a compute service
  4. Link the resource to the compute service
  5. Delete the resource link, config store entries, and config store. Try to apply the plan, and you should get an error as it tries to delete the resource before updating the service to remove the resource link.
kpfleming commented 3 months ago

That's going to be tricky, because the Config Store can't be deleted until after the new service-version (which does not reference it) has been activated. It's not sufficient to just clone the 'active' service-version and remove the Config Store link; that service-version has to be made inactive before the existing link will become inactive itself.