Skip to content

Commit 472e85b

Browse files
committed
Do not clear resources from the state based on NotFound errors
We encountered an issue where the database was unavailable while running the Terraform Zitadel provider with an `action` resource. After some debugging we found that Zitadel itself returned an error, but it looks like the middleware (potentially as obfuscation strategy) converts the error into a `NotFound` error: https://github.com/zitadel/zitadel/blob/main/internal/api/grpc/server/middleware/instance_interceptor.go#L92-L111 So considering this behavior in the Zitadel API it seem to be a bug to depend on the error code to determine if the resource should be removed from the state. In our case it caused the resource to be removed while it actually did exist. So trying to run another `terraform apply` when the database was running again, caused errors like: ``` Error: failed to create action: rpc error: code = AlreadyExists desc = Errors.Action.AlreadyExists (V3-DKcYh) ``` Note that resetting/clearning the ID is still done at the end of this function, unless there is exactly 1 result. So functionally that didn't change.
1 parent 5395c96 commit 472e85b

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

zitadel/action/funcs.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ func read(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagn
120120
}},
121121
},
122122
})
123-
if err != nil && helper.IgnoreIfNotFoundError(err) == nil {
124-
d.SetId("")
125-
return nil
126-
}
127123
if err != nil {
128124
return diag.Errorf("failed to list actions")
129125
}

0 commit comments

Comments
 (0)