-
Notifications
You must be signed in to change notification settings - Fork 142
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
allow service to be reused #578
Conversation
}) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
if !d.Get("reuse").(bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be clearer to make this a check for force_destroy instead of not reuse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because if the user doesn't specify anything then this breaks the current behaviour.
e.g. currently, if the user has a deactivated service and they don't specify force_destroy
, then the service will successfully be deleted. By changing the condition to be d.Get("force_destroy").(bool)
we're effectively saying they have to add force_destroy
to delete their deactivated service. By negating the reuse check we can keep the existing behaviour while supporting the new behaviour.
Co-authored-by: Andrew Betts <[email protected]>
Fixes #515
Summary: add
reuse
attribute tofastly_service_compute
andfastly_service_vcl
that causesterraform destroy
to not fully delete the service.See my notes for the full details and my manual validation of this change set, and the various caveats:
#515 (comment)
NOTE: I've manually tested this feature, and found it to work (see comment) but there are no tests written because the Terraform test framework expects resources to be destroyed at the end of each e2e test, and this PR implements a feature that sits outside that scenario, and so any test we write would fail unless written in a really janky way and additionally we'd need to implement a post-test process to then clean-up the service resource that was set to persist being destroyed.
Flow Examples
terraform destroy
: service not activatedforce_destroy
== no deactivation service API call, delete service API call (successful)reuse
== no deactivation service API call, no delete service API call (basically a no-op)terraform destroy
: service activatedforce_destroy
== deactivate service API call (successful), delete service API call (successful)reuse
== deactivate service API call (successful)