Manual removal of a resource on provider will raise a "404 Not Found" error without any recover
Created by: marimp
Hi there,
Terraform Version
not related to the terraform version
Affected Resource(s)
all resources
Terraform Configuration Files
not related to Configuration File
Debug Output
N/A
Panic Output
N/A
Expected Behavior
A correct approach should be something like this (in this way the provider will be locally updated):
project, tag, err := projectAndTagFromID(d.Id())
if err != nil {
if strings.Contains(err.Error(), "404 Not Found") {
d.SetId("")
return nil
}
return err
}
Actual Behavior
there is a generic issue regarding the READ resource operation.
Considering as example the resource resource_gitlab_tag_protection.go
(method resourceGitlabTagProtectionRead
) code
...
project, tag, err := projectAndTagFromID(d.Id())
if err != nil {
return err
}
...
In this way if the resource is not present on the server (404 Not Found response code), the provider return an error without deleting the local resource.
Steps to Reproduce
N/A
Important Factoids
N/A
References
N/A
Is it possible to implement this approach in all resources? Great Thanks for your attention M.