Hey guys, so I’m trying to move our Gamification setup to Terraform using CX as Code and I keep getting hit with a ‘404 resource not found’ error on the ‘genesyscloud_gamification_profile’ resource. I’ve double checked the IDs for the metrics and the divisions, and they look fine in the state file. It seems like the profile is trying to create before the metrics are fully associated? Anyone else seen this happen? It’s really messing with our automated engagement program rollout.
I think I understand your problem. The Gamification profiles have very strict dependencies on the underlying performance metrics. If you are creating new metrics in the same Terraform apply, you must use the ‘depends_on’ attribute to make sure the metrics are finished first.
Sometimes the Genesys API returns success for the metric but the backend is still processing. I usually add a small delay or use the ‘depends_on’ to be safe.
It is a common issue with CX as Code.
This is why I hate taking over these half-finished Terraform implementations. The previous dev didn’t use modules correctly. You are likely missing the ‘genesyscloud_gamification_scorecard’ link.
If the scorecard is not perfectly aligned with the profile, the API will throw a 404 because the parent container is technically missing. It is a very brittle resource type.
I am seeing this in our ServiceNow automation flows as well. When we try to provision a new user and assign them to a profile via the API, we have to wait at least 5-10 seconds for the profile to become ‘Active’ in the directory. If Terraform is moving too fast, it will error out.
Try adding a local-exec sleep if the ‘depends_on’ is not enough.