Script resource validation fails on dynamic variable reference

My current config is completely failing…

terraform apply fails with 422 Unprocessable Entity on genesyscloud_script resource.

  • Provider: 1.47.0
  • Terraform: 1.7.4
  • Region: AP-SYDNEY-1

The script content JSON references a local variable for the prompt text. Validation rejects the placeholder syntax.

snippet:

resource "genesyscloud_script" "test" {
 name = "dynamic_script"
 content = jsonencode({
 prompts = [
 { text = var.dynamic_text }
 ]
 })
}

Error states invalid prompt structure. Is variable interpolation unsupported in script content JSON?

The Terraform provider expects static JSON for genesyscloud_script, so dynamic variable interpolation inside jsonencode breaks the schema validation. Use the genesyscloud_script_version resource with a separate file provisioner or construct the entire payload in a local variable before passing it to the resource.

Using a local variable to build the JSON payload before passing it to the resource works perfectly. The validation passes, and the script deploys without the 422 error. Just remember to validate the JSON structure locally first to avoid runtime issues.

Note: Ensure the variable type is explicitly defined to prevent unexpected type coercion during the jsonencode step.