atmos terraform state replace-provider
Use this command to replace a provider in the Terraform state for an Atmos component in a stack.
Usage
Execute the terraform state replace-provider command like this:
atmos terraform state replace-provider <component> -s <stack> <from-provider> <to-provider> [options]
This command replaces the provider source for all resources managed by the specified provider. This is useful when a provider has been renamed, moved to a different namespace, or forked.
State manipulation commands should be used carefully. Always back up your state before making changes.
Run atmos terraform state replace-provider --help to see all the available options
Examples
# Replace a provider namespace
atmos terraform state replace-provider vpc -s dev \
"registry.terraform.io/-/aws" \
"registry.terraform.io/hashicorp/aws"
# Replace a forked provider
atmos terraform state replace-provider vpc -s dev \
"registry.terraform.io/hashicorp/aws" \
"registry.terraform.io/my-org/aws"
Arguments
component(required)Atmos terraform component.
from-provider(required)The source provider address to replace (e.g.,
registry.terraform.io/-/aws).to-provider(required)The target provider address to replace with (e.g.,
registry.terraform.io/hashicorp/aws).
Flags
--stack(alias-s) (required)Atmos stack.
--dry-run(optional)Show what would be executed without actually running the command.
atmos terraform state replace-provider vpc -s dev --dry-run old-provider new-provider--skip-init(optional)Skip running
terraform initbefore executing the command.atmos terraform state replace-provider vpc -s dev --skip-init old-provider new-provider
Native Terraform Flags
The atmos terraform state replace-provider command supports native terraform state replace-provider flags. Pass them directly or use -- to separate Atmos flags from Terraform flags.
-auto-approveSkip interactive approval of the provider replacement.
atmos terraform state replace-provider vpc -s dev -auto-approve old-provider new-provider-lock=trueLock the state file when locking is supported. Defaults to
true.atmos terraform state replace-provider vpc -s dev -lock=false old-provider new-provider-lock-timeout=DURATIONDuration to retry a state lock. Defaults to
0s.atmos terraform state replace-provider vpc -s dev -lock-timeout=30s old-provider new-provider-ignore-remote-versionIgnore remote state version constraints when performing the operation.
atmos terraform state replace-provider vpc -s dev -ignore-remote-version old-provider new-provider
See Also
atmos terraform state- State management overviewatmos terraform state mv- Move an item in the stateatmos terraform state list- List resources in the state