Oauth client for Integration in Genesys Cloud through Terraform

Hello all,

I asked this question already in one of the topics, but I still can not solve the problem. I need to connect Integration with pureCloudOAuthClient, but without hard coding the clientId and clientSecret. I will leave a piece of my code here and ask for help, it would be greate if some of you could help me;)

resource "genesyscloud_oauth_client" "example-client" {
name = "Example Data Actions Client"
access_token_validity_seconds = 86400
authorized_grant_type = "CLIENT-CREDENTIALS"
state = "active"
roles {
role_id = data.genesyscloud_auth_role.agent_role.id
division_id = data.genesyscloud_auth_division.division.id
}
}
data "genesyscloud_auth_role" "agent_role" {
name = "Master Admin"
}
data "genesyscloud_auth_division" "division" {
name = "Home"
}
resource "genesyscloud_integration" "integration" {
intended_state = "ENABLED"
integration_type = "purecloud-data-actions"
config {
name = "Test"
credentials = {
pureCloudOAuthClient = genesyscloud_integration_credential.credential.id
}
}
}
resource "genesyscloud_integration_credential" "credential" {
name = "credential"
credential_type_name = "pureCloudOAuthClient"
fields = {
clientId = genesyscloud_oauth_client.example-client.id
clientSecret = genesyscloud_oauth_client.example-client.clientSecret
}
}

I am looking forward to your replys
Best regards
Mariia

2 Likes

Hi Maria!

Not sure if that helps, but I do it like this:

  • define the variable with a dummy value, eg. oauthclient_id ="xyz"in the terraform.tfvars file
  • use the variable in the code:
provider "genesyscloud" {
  oauthclient_id = var.oauthclient_id
  oauthclient_secret = var.oauthclient_secret
  aws_region = var.aws_region
  sdk_debug = true
}
  • Finally, the real parameter is passed at runtime:
    terraform apply -var aws_region=$1 -var oauthclient_id=$2 -var oauthclient_secret=$3

Best,

Syxtus

Hi Maria,

You can also do this by setting the following environment variables:

GENESYSCLOUD_OAUTHCLIENT_ID=MYCLIENTID
GENESYSCLOUD_OAUTHCLIENT_SECRET=MYCLIENTSECRET
GENESYSCLOUD_REGION=YOUR REGION

With these environment variables set, you do not need to set oauthclient_id, oauthclient_secret, aws_region. You can find configuration information about the provider here.

Thanks,
John Carnell
Director, Developer Engagement

@Syxtus_Gaal @John_Carnell, thank you so much for your answers. How I understood it is helpful with the oauth client that is already created and I am working with that, but is it also be working with the client that is only in process of creation and I am not working from it? So I need to in one-time terraform plan, apply create client and integration and take credentials from that client that is creating.

Best regards
Mariia

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.