Looking for advice on handling state drift for genesyscloud_analytics_report_resource. The HCL definition is static, but the API returns a different report_id after each apply in the au-1 region.
Is there a way to pin the report ID in the resource block to prevent constant recreation?
You need to shift away from trying to pin the internal report_id directly in the Terraform resource block, as that identifier is often generated or mutated by the Genesys Cloud backend during the initial creation phase, especially in specific regions like au-1. Instead of fighting the state drift on the ID itself, focus on defining a stable unique_name or title attribute within your HCL configuration.
The Genesys Cloud Terraform provider is designed to handle lookups based on these immutable user-defined fields. By ensuring the name parameter is consistent and unique across your environment, the provider can correctly associate the existing resource with your state file, regardless of the underlying UUID changes. This approach aligns with how we handle similar drift issues in ServiceNow integrations where internal sys_ids fluctuate but ticket numbers remain constant. Ensure you are also using the latest provider version, as recent updates have improved the reconciliation logic for analytics resources. Check the lifecycle block if you still see unnecessary updates, but usually, a stable name is sufficient.
import {
to = genesyscloud_analytics_report_resource.my_report
id = “existing-report-id”
}
> The HCL definition is static, but the API returns a different report_id after each apply
Pinning the ID is not the correct approach. The identifier is immutable once created. Using the import block aligns the state with the existing resource, preventing unnecessary recreation while maintaining the dashboard metrics structure.
How I usually solve this is by pinning the unique_name in the HCL, which acts like a Zendesk ticket ID to prevent duplicate creations.
resource "genesyscloud_analytics_report_resource" "report" {
unique_name = "my-stable-report"
}
This ensures the state matches the existing resource without fighting the backend ID generation.