mrparkers / terraform-provider-keycloak

Terraform provider for Keycloak
https://registry.terraform.io/providers/mrparkers/keycloak/latest/docs
MIT License
617 stars 303 forks source link

error handling protocol mappers in keycloak_client_description_converter #751

Open horus opened 1 year ago

horus commented 1 year ago

Hello,

Related module: data_source_keycloak_client_description_converter Version tested: 3.10.0, 4.0.0

data "keycloak_client_description_converter" "saml_client" {
    realm_id = keycloak_realm.realm.id
    body     = file("./saml-metadata.xml")
}

With this example, we expected protocol mappers to be saved in example.tfstate as:

"origin": "",
"protocol": "saml",
"protocol_mappers": [
      {
       "config": {
         "attribute.name": "https://aws.amazon.com/SAML/Attributes/Role",
         "friendly.name": "RoleEntitlement"
       },
       "id": "",
       "name": "https://aws.amazon.com/SAML/Attributes/Role",
       "protocol": "saml",
       "protocol_mapper": "saml-user-attribute-mapper"
      },

Actual result:

"protocol_mappers": []

The Keycloak API /{realm}/client-description-converter responded correctly.

Example error message with TF_LOG=TRACE on:

2022-10-10T18:56:18.778+0800 [INFO]  provider.terraform-provider-keycloak_v3.10.0: 2022/10/10 18:56:18 [ERROR] setting state: Invalid address to set: []string{"protocol_mappers", "0", "ProtocolMapper"}: timestamp=2022-10-10T18:56:18.775+0800

I've prepared an potential fix for the issue here: https://github.com/horus/terraform-provider-keycloak/commit/32d1e31793c40e4c41fc1122999e6aa87a284131. If there's anything I could help please let me know. Thank you!

missedone commented 6 months ago

@mrparkers, i'm facing the same issue, is there any change to support the protocol mappers?