atmos terraform force-unlock
Use this command to manually unlock the Terraform state for an Atmos component in a stack when automatic unlocking fails.
Usage​
Execute the terraform force-unlock command like this:
atmos terraform force-unlock <component> <lock-id> -s <stack> [options]
This command manually unlocks the state for the defined configuration. This is useful when automatic unlocking fails due to a process crash or network issue. Use with caution as it can cause state corruption if another process is actually using the state.
Atmos provides standard setup for this command including automatic terraform init and workspace selection. The unlock operation itself is handled by native Terraform.
Examples​
Force Unlock State​
# Unlock using a specific lock ID
atmos terraform force-unlock vpc -s dev abc123-lock-id
Example Lock Error and Resolution​
# When you see an error like:
# Error: Error acquiring the state lock
# Lock Info:
# ID: abc123-xyz789
# Path: s3://bucket/terraform.tfstate
# Operation: OperationTypePlan
# Who: user@machine
# Version: 1.0.0
# Created: 2024-01-15 10:00:00 +0000 UTC
# Force unlock with the lock ID:
atmos terraform force-unlock vpc -s dev abc123-xyz789
Arguments​
component(required)Atmos component name.
lock-id(required)The Terraform state lock ID to force unlock. This ID is displayed in the error message when a lock conflict occurs. Example format:
abc123-xyz789-def456.
Flags​
--stack/-s(required)Atmos stack name where the component is defined.
--skip-init(optional)Skip running
terraform initbefore executing the command.atmos terraform force-unlock vpc -s dev --skip-init--dry-run(optional)Show what would be executed without actually running the command.
atmos terraform force-unlock vpc -s dev --dry-run
Native Terraform Flags​
The lock ID is a required positional argument. To pass native Terraform flags like -force to skip confirmation, use a double-dash separator:
atmos terraform force-unlock vpc abc123-lock-id -s dev -- -force
Related Commands​
atmos terraform plan- Generate execution planatmos terraform apply- Apply changesatmos terraform init- Initialize working directory