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
59 stars 16 forks source link

Inconsistent property_mappings behavior in authentik_provider_proxy #470

Open diegmonti opened 4 months ago

diegmonti commented 4 months ago

Issue Description

When creating a Terraform resource authentik_provider_proxy with a property_mappings array, the state of the resource on the server becomes inconsistent with respect to the state in the configuration.

Steps to Reproduce

  1. Define the following Terraform configuration:
resource "authentik_scope_mapping" "my_mapping" {
  name       = "my_mapping"
  scope_name = "my_mapping"
  expression = [...]
}
resource "authentik_provider_proxy" "provider_proxy" {
  name              = "example"
  mode              = "forward_single"
  external_host     = "https://my.example.com"
  property_mappings = [authentik_scope_mapping.my_mapping.id]
}
  1. After creating the resources, run again terraform apply.

Observed Behavior

Each time terraform apply is executed, Terraform attempts to modify the resource to remove some property_mappings:

  ~ resource "authentik_provider_proxy" "provider_proxy" {
      ~ property_mappings            = [
            "my_mapping_id",
          - "managed_mapping_id_1",
          - "managed_mapping_id_2",
          - "managed_mapping_id_3",
          - "managed_mapping_id_4",
        ]
    }

Expected Behavior

The resource should maintain consistency between the configuration and the server state. Terraform should not attempt to remove "managed_mapping_id_1", "managed_mapping_id_2", "managed_mapping_id_3", and "managed_mapping_id_4", as these are considered "managed mappings" and should not be altered by Terraform during plan execution.

managed mappings