goauthentik / terraform-provider-authentik

Manage https://goauthentik.io with terraform.
https://registry.terraform.io/providers/goauthentik/authentik/latest/docs
GNU General Public License v3.0
58 stars 16 forks source link

False negatives when refreshing state of resources #479

Closed valkenburg-prevue-ch closed 4 months ago

valkenburg-prevue-ch commented 4 months ago

I am seeing this in many different resources with the authentik provider: a resource was created in the past, and an subsequent "terraform apply" will falsely try to create the resource, either thinking it does not currently exist or it has changed and needs to be replaced. For example:

resource "authentik_provider_proxy" "the_proxy" {
  count                  = 1
  name                  = "some-proxy"
  mode                  = "forward_single"
  internal_host         = null 
  external_host         = "https://some-service.example.com"
  authorization_flow    = data.authentik_flow.default-authorization-flow.id
  access_token_validity = "hours=12" 
}

With the following logs:

authentik_provider_proxy.the_proxy[0]: Refreshing state... [id=1]

and then

Error: HTTP Error '400 Bad Request' during request 'POST /api/v3/providers/proxy/': "{"name":["provider with this name already exists."]}"

I have no idea how to reproduce this. Currently on provider version 2024.2.0, and authentik 2024.2.1.

valkenburg-prevue-ch commented 4 months ago

Argh, it is a non-issue. Sorry. The error is entirely on my end, outside of the provider: I am creating all mentioned resources in a module, and I had a wrong count on the module. The count should be 1, but was a larger number, so all resources were created multiple times. The error message that the resource already exists, was hence correct.

Closing.