Skip to main content

atmos terraform state push

Use this command to update the remote Terraform state from a local state file for an Atmos component in a stack.

atmos terraform state push --help

Usage

Execute the terraform state push command like this:

atmos terraform state push <component> -s <stack> <path-to-state-file> [options]

This command uploads a local state file to the remote backend. This is primarily used for disaster recovery or migrating state between backends.

caution

This is a dangerous operation. The remote state will be overwritten with the contents of the local file. Always create a backup using terraform state pull before pushing.

tip

Run atmos terraform state push --help to see all the available options

Examples

# Push a local state file to remote
atmos terraform state push vpc -s dev vpc-state-backup.json

# Force push (override lineage check)
atmos terraform state push vpc -s dev -force vpc-state-backup.json

Arguments

component (required)

Atmos terraform component.

path-to-state-file (required)

Path to the local state file to push to the remote backend.

Flags

--stack (alias -s) (required)

Atmos stack.

--dry-run (optional)

Show what would be executed without actually running the command.

atmos terraform state push vpc -s dev --dry-run vpc-state-backup.json
--skip-init (optional)

Skip running terraform init before executing the command.

atmos terraform state push vpc -s dev --skip-init vpc-state-backup.json

Native Terraform Flags

The atmos terraform state push command supports native terraform state push flags. Pass them directly or use -- to separate Atmos flags from Terraform flags.

-force

Write the state even if lineages don't match or the remote serial is higher.

atmos terraform state push vpc -s dev -force vpc-state-backup.json
-lock=true

Lock the state file when locking is supported. Defaults to true.

atmos terraform state push vpc -s dev -lock=false vpc-state-backup.json
-lock-timeout=DURATION

Duration to retry a state lock. Defaults to 0s.

atmos terraform state push vpc -s dev -lock-timeout=30s vpc-state-backup.json
-ignore-remote-version

Ignore remote state version constraints when performing the operation.

atmos terraform state push vpc -s dev -ignore-remote-version vpc-state-backup.json

See Also