Hi all,
It’s happening again. This peculiar state drift issue with Architect flows, specifically regarding scripted updates to variables - feels like déjà vu from about three years ago when we first moved everything to Terraform. The symptoms are… subtle. Flows aren’t breaking, exactly, but the variable values aren’t sticking after a Terraform apply. It’s maddening.
We’ve got a flow - a basic IVR - where a script is updating a flow variable ($current_timestamp) with the current UTC time. Simple enough. The script itself is a straightforward JavaScript block:
export default function(context, event, callback) {
let now = new Date().toISOString();
context.vars.$current_timestamp = now;
callback(null, context);
}
The initial Terraform import worked fine. State looked correct. But then, a minor change to the script - adding a console log for debugging - and subsequent terraform apply resulted in the flow variable being reset to its default value whenever the flow is executed. It’s as if Terraform isn’t correctly detecting the script update.
PlatformClientV2 actually enforces a strict schema validation pass on the flow’s configuration during the apply, and it appears the script block is being completely replaced instead of updated. It’s not a permissions problem - the service account has full access. We’ve checked the Terraform provider version (v3.63.0) and confirmed it’s up to date. The provider’s documentation on flow variable updates is…sparse.
Years ago, we found this was related to how Terraform handled the body attribute within the genesys.cloud.architect.Script. It needed to be a complete string, including the script’s metadata, and not just the script content itself. We had to switch to base64 encoding the entire script block, then decode it within the Terraform configuration. It was a messy workaround.
The question is, has anyone else run into this recently? I’m hesitant to re-implement the base64 encoding scheme - it adds unnecessary complexity. Is there a more elegant solution, or are we back to wrestling with Terraform’s quirks again? The flow ID in question is 67a3b9d8-1234-5678-9abc-def012345678. It’s just… irritating.