Upsert a Workspace Variable
A 4-step recipe with Terraform. We can help you get access.
Recipe · 4 steps
Upsert a Workspace Variable
with Terraform
Create or update a single workspace variable by key.
- List every variable on the workspace so the target key can be matched against what is already configured.
- Patch the existing variable with the new value. Only the supplied attributes change; the variable's category and identity are preserved.
- Create the variable on the workspace when no variable with the target key was found.
- Read the workspace variable list back to confirm the upsert landed and the workspace holds exactly one variable with the target key.
What you'll need to have ready
- workspaceId: The workspace identifier to write the variable to.
- variableKey: The variable key to upsert (e.g. "instance_type").
- variableValue: The value to write for the variable.
- variableCategory: Whether this is a "terraform" input variable or an "env" variable.
- variableDescription: A human readable description stored alongside the variable.
- variableHcl: Whether the value should be parsed as HCL rather than a literal string.
- variableSensitive: Whether the value should be write-only and hidden from reads.
For your developer
Arazzo workflow terraform:upsert-workspace-variable, 4 operations: ListWorkspaceVariables → UpdateWorkspaceVariable → CreateWorkspaceVariable → ListWorkspaceVariables. Specs on APIs.io.