In a Continuous Integration setup (Jenkins) I'd like to deploy (terraform apply) changes of the same Terraform configuration code using multiple workspaces at the same time using the same copy of the repository - i.e. the very same directory with .tf files.
Stages are executed in parallel (on same node/agent) and each of them consists of the same sequence of operations (terraform workspace select and then terraform apply).
It doesn't seem supported as the attempts fail with lock errors, e.g.
# terraform workspace select "workspace1"
# terraform apply [...] -input=false -auto-approve
Switched to workspace "workspace1".
Acquiring state lock. This may take a few moments...
Error: Error locking state: Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed
Lock Info:
ID: 52973611-a892-deac-985b-5aa28172fdaf
Path: my-project/env:/workspace5/state
Operation: OperationTypeApply
Who: @87ddd2118473
Version: 0.13.5
Created: 2021-01-11 15:20:06.635256155 +0000 UTC
Info:
So it looks like lock for workspace5 gets in the way for applying for workspace1.
Is there any way out?
I use:
- Terraform 0.13.5
s3as the backend- DynamoDB for locks