terraform-provider-fusionauth icon indicating copy to clipboard operation
terraform-provider-fusionauth copied to clipboard

client_id not working on Application create

Open M-Whitaker opened this issue 2 years ago • 2 comments

As per the api specification, fusion auth supports supplying a client_id and client_secret: https://fusionauth.io/docs/v1/tech/apis/applications#create-an-application.

It looks like from my testing and reading a bit of the code (very new to terraform so maybe reading wrong) the provider doesn't support this field at the moment.

Was there reason for this? I'm happy to contribute.

M-Whitaker avatar May 11 '23 07:05 M-Whitaker

@M-Whitaker I am not affiliated with FusionAuth but might be able to help.

From the API Reference you shared, I see applications[x].oauthConfiguration.clientId, application.oauthConfiguration.clientId, and oauthConfiguration.clientId all exist as part of the Response only. I can't see it anywhere in the Request data.

That being said, I believe there is a bug in the provider, just not in the way you are describing it. I think the bug lies in the oauth_configuration block, whereby it accepts the client_id attribute but the FusionAuth Provider can never set the value through the API, resulting in a perma-diff:

The following example configuration will set the fusionauth_application.oauth_configuration[0].client_id from the autogenerated value to complete-novice, applies 'successfully', but then computes the same diff over and over:

data "fusionauth_tenant" "default"{
    name = "Default"
}

resource "fusionauth_application" "example" {
  name      = "example"
  tenant_id = data.fusionauth_tenant.default.id

  oauth_configuration {
    client_id = "complete-novice"
  }
}

completenovice avatar May 19 '23 14:05 completenovice

Ah, I now see where I went wrong. Ctrl F not working in my favour. Thanks for pointing this out and also the reference to the bug in the terraform provider that allows this and doesn't call it out as a validation error.

M-Whitaker avatar May 19 '23 14:05 M-Whitaker