Genesyscloud_security_data_masking 409 Conflict on Apply

Could someone clarify why the provider throws a 409 when applying data masking rules via Terraform?

Provider: 1.15.0
Region: apac-1

HCL applies to dev, but prod fails on second run.

POST /api/v2/security/datamaskings
409 Conflict: Resource conflict. Data masking configuration already exists.

State shows no drift. API returns 404 for GET on same ID. Is this a caching issue or API bug?

This is actually a known issue… The 409 usually stems from orphaned resources in the backend database that the API hasn’t fully garbage-collected yet, especially in APAC regions where replication lag can be higher. Since the GET returns a 404 but the POST fails, the system thinks the resource exists but can’t retrieve it.

  • Try waiting 15-20 minutes for the cache to invalidate before retrying the apply.
  • Check the Genesys Cloud Admin Console under Security > Data Masking to see if a “ghost” record appears there. If it does, delete it manually.
  • If the console shows nothing, contact Support with the request ID from the 409 response. They can often clear the stuck state from the database side.
  • Avoid running concurrent applies to the same security configuration; this exacerbates the locking mechanism.

This isn’t a Terraform bug, but rather a race condition in the Genesys API’s conflict detection logic. Patience is key here.

Make sure you verify the actual resource existence via the API directly before blaming replication lag. The 409 often persists because the backend index is stale while the object store is clean. Run a simple curl GET with verbose logging to confirm the ID truly returns 404. If it does, the provider might be retrying too fast. Add a small sleep in the Terraform lifecycle hooks to allow the cache to clear. This usually resolves the conflict without manual console intervention.