`atmos terraform force-unlock` does not work
Describe the Bug
atmos terraform force-unlock worked before but probably only randomly and doesn't work at all anymore (I guess) since v1.100 which now always cleans the workspace. See below for an example.
I guess the proper solution would be to skip the workspace switch for force-unlock.
Expected Behavior
atmos terraform force-unlock should work.
Steps to Reproduce
- Configure an S3 backend with a DynamoDB database for locking.
- Start some
atmos terraform $component --stack $stack applybut cancel it right in the middle by hitting via Ctrl+C twice. - Try
atmos terraform plan $component --stack $stack - Try
atmos terraform force-unlock $component --stack $stack $uuidwhere uuid is the value from the previous error.
Screenshots
# atmos terraform force-unlock wms-base --stack wms-xe02-sandbox 8ac7bbfc-c1b4-615d-38d7-f7ba634aa4bb --skip-init
Workspace "wms-xe02-sandbox-wms-base" doesn't exist.
You can create this workspace with the "new" subcommand
or include the "-or-create" flag with the "select" subcommand.
failed to lock s3 state: operation error DynamoDB: PutItem, https response error StatusCode: 400, RequestID: GK00L3DNLAJF2N4KSMUCPHAMA3VV4KQNSO5AEMVJF66Q9ASUAAJG, ConditionalCheckFailedException: The conditional request failed
Lock Info:
ID: 8ac7bbfc-c1b4-615d-38d7-f7ba634aa4bb
Path: sl-atmos-tfstate-123456789012/wms/xe02/sandbox/wms-xe02-sandbox-wms-base/terraform.tfstate
Operation: OperationTypeApply
Who: stretz@slpn-nb-mss
Version: 1.8.5
Created: 2024-11-22 13:59:40.20546289 +0000 UTC
Info:
exit status 1
Environment
- Version 1.105.0
Additional Context
No response
@mss thank you for reporting this
Just using the default workspace (via TF_WORKSPACE=default) doesn't work, results in the error Failed to unlock state: failed to retrieve lock info for lock ID "8ac7bbfc-c1b4-615d-38d7-f7ba634aa4bb": unexpected end of JSON input. From running the whole thing with TF_LOG=debug it looks like the LockID is wrong.
This doesn't work either:
TF_WORKSPACE=default atmos terraform shell wms-base --stack wms-xe02-sandbox
unset TF_WORKSPACE
terraform workspace new -lock=false wms-xe02-sandbox-wms-base
terraform force-unlock 8ac7bbfc-c1b4-615d-38d7-f7ba634aa4bb
The terraform workspace new fails already. Looks like the -lock=false is ignored so there may be a terraform bug involved as well?
Hi @mss We are tracking this bug and will look into it. Can not promise an ETA though
I think this is at least partially broken on the Terraform side, cf. linked ticket.
@aknysh FYI