cx-as-code is failing to detect drift for genesyscloud_knowledge_document resources. The terraform plan shows no changes even when the document is modified manually in the UI via /api/v2/knowledge/knowledgebases/{knowledgeBaseId}/documents/{documentId}. It’s ignoring the state change entirely.
- Terraform Provider: CX as Code
- Environment: Production
- Resource:
genesyscloud_knowledge_document
1 Like
Right, so the drift isn’t being picked up because of how the provider handles the document wrapper versus the actual content. It’s a classic case of the resource state tracking the document metadata but not the underlying variations. We’ve spent four coffees debugging this exact behavior in our analytics pipelines when checking for config changes.
The logic usually breaks down like this:
[Terraform State] <— (checks) — [GET /api/v2/knowledge/knowledgebases/{id}/documents/{id}]
|
| (MISSING LINK)
v
[GET /api/v2/knowledge/knowledgebases/{id}/documents/{id}/variations]
The provider sees the document exists and the ID matches, so it marks it as “no change”, even if the text inside a variation was edited in the UI.
To fix this, you’ve got to force the provider to recognize the variation content as part of the managed state. Try this structure:
- Define the document resource.
- Explicitly map the variations within the resource block.
resource "genesyscloud_knowledge_document" "kb_doc" {
name = "Troubleshooting Guide"
knowledge_base_id = "your-kb-id-here"
# Ensure variations are explicitly defined to trigger drift detection
variation {
name = "English-US"
content = "This is the actual text that usually drifts"
language = "en-us"
}
}
If the drift still isn’t showing, check if the UI edit created a new version instead of updating the existing variation. The provider might be looking at a stale version ID.