Skip to main content

atmos terraform refresh

Use this command to refresh the Terraform state for an Atmos component in a stack, updating it to match the current remote infrastructure.

atmos terraform refresh --help

Usage​

Execute the terraform refresh command like this:

atmos terraform refresh <component> -s <stack> [options]

This command reads the current settings from all managed remote objects and updates the Terraform state to match. This won't modify your infrastructure but will update the state file.

Atmos Enhancements

Atmos enhances the refresh command with:

  • Automatic terraform init before refreshing
  • Workspace selection and management
  • Automatic variable file generation and passing
  • Backend configuration
  • Component validation

Examples​

Basic Refresh​

# Refresh the state for a component
atmos terraform refresh vpc -s dev

Targeted Refresh​

# Refresh specific resources only
atmos terraform refresh vpc -s dev -target=aws_instance.web

Refresh with Variable Override​

# Refresh with different variable values
atmos terraform refresh vpc -s dev -var="instance_type=t3.large"

Arguments​

component (required)

Atmos component name.

Flags​

--stack / -s (required)

Atmos stack name where the component is defined.

--skip-init (optional)

Skip running terraform init before executing the command.

atmos terraform refresh vpc -s dev --skip-init
--dry-run (optional)

Show what would be executed without actually running the command.

atmos terraform refresh vpc -s dev --dry-run

Native Terraform Flags​

This command supports native terraform refresh flags such as -target=RESOURCE to refresh specific resources, -var to override variables, -var-file to specify variable files.