-
Notifications
You must be signed in to change notification settings - Fork 139
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
Conflict when recreating a snippet #628
Comments
Hi @sjparkinson Thanks for opening this issue. I'll investigate this further as it looks like we should 'delete', then 'add', then 'update': terraform-provider-fastly/fastly/service_crud_attribute_definition.go Lines 102 to 127 in 072d14c
|
OK, so the problem is that we currently process versioned snippets first before dynamic snippets... terraform-provider-fastly/fastly/resource_fastly_service_vcl.go Lines 54 to 55 in 072d14c
So if you were to define a versioned snippet and then switched to a dynamic snippet, the order works. This is because the provider will delete the versioned snippet first, and then move to the creation of the dynamic snippet. If (as you have in your example) start with a dynamic snippet and switch to a versioned snippet, then the order breaks because the provider will end up creating the versioned snippet first, which causes the API conflict to be raised. We can't just move the I don't know of a way to resolve this without a significant rewrite of the snippets architecture inside of the provider. I'll leave this issue open because it is a bug in the provider, and in the meantime, I'll consult internally to see if anyone has any other suggestions. For now, you'll need to do this as two separate plan/apply steps to avoid the conflict. |
That's helpful, and sort of how we've unpicked ourselves so far. Thank you. I wouldn't mind seeing non-unique snippet names if you want to pitch for another sort of unique ID for them in the API! |
@sjparkinson Well, there is a new Terraform plugin framework (which replaces the current v2 SDK). For us to support the new framework will be a significant piece of work, and definitely a new major release (due to various breaking changes), and so as part of that work (no ETA on that of course, we have not scheduled anything yet) I would expect to consolidate Then we would be able to expose a The underlying API for both types is the same and all the API client does is pass a flag to toggle between dynamic and versioned: see the API documentation. |
👋🏻 @sjparkinson I forgot to mention if you wanted to follow along with my (personal) progress on a Fastly provider that supports the new HashiCorp 'framework', then I can refer you to https://github.com/Integralist/terraform-provider-fastly-framework (in that project see the CHANGELOG and DEVELOPMENT files for extra context/info). |
Terraform Version
Affected Resource(s)
fastly_service_vcl
Terraform Configuration Files
From
To
Debug Output
Expected Behavior
In order to avoid a conflict when converting a dynamic snippet into a standard snippet with the same name:
Or vice versa if going in the other direction, the key being for any snippet deletions to occur before snippet creations to avoid conflicts if the name is identical.
Actual Behavior
The API request to create the standard snippet occurs before the request to delete the dynamic snippet.
Important Factoids
We're seeing this in relation to converting the
WAF_Prefetch
Legacy WAF dynamic snippet into a standard snippet.The text was updated successfully, but these errors were encountered: