Terraform and CX as code organization API error

Hi ,

I am encountering an issue where, whenever I run terraform apply or terraform plan, I receive the following error:

│ Error: GET https://api./api/v2/organizations/me giving up after 21 attempt(s): Get "https://api./api/v2/organizations/me": dial tcp: lookup api.: no such host
│
│   with provider["registry.terraform.io/mypurecloud/genesyscloud"],
│   on main.tf line 22, in provider "genesyscloud":
│   22: provider "genesyscloud" {
│
╵
Releasing state lock. This may take a few moments...

I have tried adding this block to my main.tf, but the problem still remains:

Null resource to execute a custom API call using curl to bypass Terraform's API issues

resource "null_resource" "custom_api_call" {
provisioner "local-exec" {
environment = {
PURECLOUD_ENVIRONMENT = "mypurecloud.ie" # Explicitly setting the environment variable
}
# Hardcoded access token for the curl command
command = "curl -X GET https://api.mypurecloud.ie/api/v2/organizations/me -H "Authorization: Bearer 2yNORk5Q1F#################################################################""
}
triggers = {
always_run = "${timestamp()}" # Ensures this runs every time Terraform is applied
}
}
Due to this specific error, I cannot use terraform plan or terraform apply. I would appreciate your assistance.

Hello

It looks like the provider doesn't know what domain to use in the requests. That's why "mypurecloud.ie" is missing

Error: GET https://api./api/v2/organizations/me

To fix this, add your region to the provider block:

provider "genesyscloud" {
  aws_region = "eu-west-1"
}

Alternatively, you could set the value of aws_region using the environment variable GENESYSCLOUD_REGION.

You can find more info about configuring your provider here - https://registry.terraform.io/providers/MyPureCloud/genesyscloud/latest/docs.

1 Like

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