@@ -91,3 +91,62 @@ For more information, refer to:
91
91
- [`atmos describe dependents` CLI command](/cli/commands/describe/dependents)
92
92
93
93
:: :
94
+
95
+ # ## Error: `A change in the backend configuration has been detected, which may require migrating existing state`
96
+
97
+ ` ` ` console
98
+ A change in the backend configuration has been detected, which may require migrating existing state
99
+ ` ` `
100
+
101
+ The Terraform/OpenTofu error means Terraform noticed that your backend configuration (the section in your code that
102
+ defines where and how Terraform stores state) has changed compared to what’s currently in use..
103
+
104
+ # ### Why it happens
105
+
106
+ Terraform keeps its state in a backend (for example, S3, local, remote, Terraform Cloud, etc.).
107
+ If you update the backend configuration in your code — for example :
108
+
109
+ - Switching from local to s3
110
+ - Changing the bucket, key, or region for an S3 backend
111
+ - Modifying a prefix or workspace config in Terraform Cloud
112
+ - Adjusting encryption or locking settings
113
+ - Terraform detects that the state might need to be migrated from the old backend to the new one.
114
+
115
+ # ### What Terraform expects
116
+
117
+ When this happens, Terraform doesn’t automatically move state — it prompts you to confirm migration.
118
+ Typically, you’ll see a message like :
119
+
120
+ ` ` ` console
121
+ Do you want to copy existing state to the new backend?
122
+ Enter "yes" to copy and "no" to start with an empty state.
123
+ ` ` `
124
+
125
+ If you type `yes`, Terraform migrates the state (so you keep your existing resources).
126
+ If you type `no`, Terraform initializes a fresh, empty state in the new backend (dangerous unless intentional).
127
+
128
+ # ### How to resolve
129
+
130
+ In `atmos.yaml`, set `components.terraform.init_run_reconfigure` to `true` :
131
+
132
+ ` ` ` yaml
133
+ components:
134
+ terraform:
135
+ # Can also be set using 'ATMOS_COMPONENTS_TERRAFORM_INIT_RUN_RECONFIGURE' ENV var, or '--init-run-reconfigure' command-line argument
136
+ init_run_reconfigure: true
137
+ ` ` `
138
+
139
+ This will tell Atmos to run `terraform init -reconfigure` when executing Terraform commands.
140
+ The `-reconfigure` option disregards any existing backend configuration and configures a new backend,
141
+ preventing migration of any existing state.
142
+
143
+ :::tip
144
+
145
+ For more information, refer to :
146
+
147
+ - [`terraform init` command](https://developer.hashicorp.com/terraform/cli/commands/init)
148
+ - [Terraform Backend Initialization](https://developer.hashicorp.com/terraform/cli/commands/init#backend-initialization)
149
+ - [Atmos CLI configuration](/cli/configuration/#configuration)
150
+ - [Atmos Terraform/OpenTofu commands](/cli/commands/terraform/usage)
151
+
152
+ :: :
0 commit comments