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.
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 enhances the refresh command with:
- Automatic
terraform initbefore 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 initbefore 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
--ui (the streaming UI
available for plan, apply, deploy, init, and destroy) is not supported for refresh,
since Terraform's refresh doesn't emit the structured -json output the streaming UI depends
on. Passing --ui prints a warning and falls back to standard output.
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.
Default Locking and Concurrency Flags
Instead of retyping flags like -lock-timeout on every invocation, declare a default
in components.terraform.flags — globally
in atmos.yaml, per stack, or per component. refresh supports lock_timeout, lock,
parallelism, and compact_warnings (there is no -refresh flag on terraform refresh
itself — refresh is what the subcommand does). A native flag typed directly on the command
line always wins over a declared default.
Related Commands
atmos terraform plan- Generate execution planatmos terraform apply- Apply changesatmos terraform init- Initialize working directory