magodo / terraform-provider-restful

Terraform provider to manage RESTful resources
https://registry.terraform.io/providers/magodo/restful
Mozilla Public License 2.0
15 stars 5 forks source link

Possible bug in oauth2_password provider configuration ("mismatch between struct and object") #61

Closed mgrolinger closed 1 year ago

mgrolinger commented 1 year ago

Error Description

I am getting a "Value Conversion Error" when I try to use the _oauth2password configuration. While _clientcrendentials work fine configuration for oauth2 password makes problems.

I am using the latest release (v 0.11.0) of the restful provider, with terraform 1.5.6.

Config

My provider configuration looks like this:

locals {
  keycloak_instance_url = "https://localhost/auth"
  token_endpoint_path = "/realms/master/protocol/openid-connect/token"
}
provider "restful" {
  base_url = local.keycloak_instance_url
  security = {
    oauth2 = {
      password = {
        username  ="keycloak_admin_username"
        password  = keycloak_admin_pw"
        token_url = format("%s%s", local.keycloak_instance_url, local.token_endpoint_path)
      }
    }
  }
}

The general config worked fine with _clientcredentials before. However, we had to switch back to an admin user without having a service account and we are stuck with the following error message.

Error message

This configuration above results in the following error message:

│ Error: Value Conversion Error
│
│   with module.service_accounts.restful_operation.change_service_account_user["test-client"],
│ An unexpected error was encountered trying to convert tftypes.Value into provider.oauth2Data. This is always an error in the provider. Please report the following to the provider developer:
│
│ mismatch between struct and object: Struct defines fields not found in object: client_credentials and refresh_token. Object defines fields not found in struct: token_url, username, client_id, client_secret, in, and scopes.

Having provided all required attributes (and none of the optional) it should work. However, I always get the above error message even when I provide additional optional attributes such as _clientid and _clientsecret.

https://registry.terraform.io/providers/magodo/restful/latest/docs