Importing existing Genesys Cloud user into Terraform state fails with 404

  • Genesys Cloud API v2
  • Terraform Provider genesyscloud 1.30.0
  • Running terraform import for existing user

Could someone explain why this import command returns a 404? I have the correct user ID from the UI but the provider seems to be looking for a different resource type or path. I am trying to manage an existing agent’s skills via code without recreating the account. The command terraform import genesyscloud_user.my_agent 12345678-1234-1234-1234-123456789012 fails immediately. Is there a specific format required for the ID?

Ah, yeah, this is a known issue with the Terraform provider when dealing with legacy user IDs or when the import ID format doesn’t match the internal resource mapping expectations. The provider often expects a specific composite ID format for certain resources, but for genesyscloud_user, it usually just needs the UUID. However, if you’re getting a 404, it’s highly likely that the user ID you’re pulling from the UI is actually the id field, but the provider’s import logic might be failing due to a mismatch in how it queries the API endpoint /api/v2/users/{id}. Before blaming the provider, verify that the user ID is correct by hitting the API directly using a simple curl command to ensure the resource exists and is accessible by your service account. Run curl -X GET "https://api.mypurecloud.com/api/v2/users/12345678-1234-1234-1234-123456789012" -H "Authorization: Bearer YOUR_TOKEN" to confirm the user returns a 200 OK. If that works, the issue is likely in the Terraform state mapping. Sometimes, you need to ensure your service account has the user:read scope explicitly granted. Also, check if the user is archived; the provider cannot import archived users. If the API call succeeds, try wrapping the ID in quotes during the import command: terraform import genesyscloud_user.my_agent "12345678-1234-1234-1234-123456789012". This prevents shell interpretation issues. Additionally, ensure you are using the latest version of the provider, as version 1.30.0 had some quirks with import logic for nested attributes like skills and teams. If the problem persists, check the provider’s debug logs by setting TF_LOG=DEBUG to see exactly which API endpoint is being called and what the response body contains. This usually reveals if the provider is appending an unexpected suffix to the ID.

The main issue here is that the terraform import command requires the exact uuid format without any trailing characters or whitespace. the suggestion above is mostly correct, but the 404 often stems from the provider attempting to fetch the resource before the api token is fully validated or if the user id contains hidden characters from copy-pasting.

ensure you are using the purecloudplatformclientv2 sdk to verify the user exists first.

const userApi = platformClient.UsersApi;
const user = await userApi.usersUserGet('12345678-1234-1234-1234-123456789012');
console.log(user.id); // verify this matches exactly

if the sdk returns the user, the id is valid. then run:

terraform import genesyscloud_user.my_agent 12345678-1234-1234-1234-123456789012

also check that your environment variables for genesyscloud are set correctly in the same shell session. the provider might be hitting a different org if the auth headers are stale. this is a common pitfall in ci pipelines where tokens expire mid-execution.

You need to verify the resource existence directly via the API before attempting the Terraform import. The provider’s import logic often fails silently with a 404 if the underlying REST call returns an unexpected payload or if the user ID format is malformed.

Could someone explain why this import command returns a 404? I have the correct user ID from the UI but the provider seems to be looking for a different resource type or path.

First, confirm the user ID is valid using the CXone REST API. Use the GET /api/v2/users/{id} endpoint with your OAuth token. If this returns 200, the ID is correct. If it returns 404, the ID from the UI might be incorrect or the user was deleted.

curl -X GET "https://api.mypurecloud.com/api/v2/users/12345678-1234-1234-1234-123456789012" \
 -H "Authorization: Bearer YOUR_OAUTH_TOKEN"

If the API call succeeds, the issue lies within the Terraform provider’s state mapping. Ensure no trailing whitespace exists in the import command. If the API call fails, retrieve the correct UUID from the response of GET /api/v2/users filtered by email or name.

Ah, yeah, this is a known issue… the 404 usually means the genesyscloud_user resource expects the uuid but you might be passing an email or external id. verify the user exists first via GET /api/v2/users/{id} with users:view scope to ensure the id is valid before running terraform import.