You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cdktf cli should trigger a state migration to the terraform process
Actual Behavior
Terraform fails to initialise and shows the following error:
Error: Backend configuration changed
│
│ A change in the backend configuration has been detected, which may require
│ migrating existing state.
│
│ If you wish to attempt automatic migration of the state, use "terraform init
│ -migrate-state".
│ If you wish to store the current configuration with no changes to the state,
│ use "terraform init -reconfigure".
changing from migrateState:this.options.migrateState to migrateState:true;
and adding ,e.migrateState&&r.push("-migrate-state") next to e.noColor&&r.push("-no-color") and before the ;;
Workaround for a possibly separate issue of migrating the state (see #3704 (comment)):
changing from Should Terraform migrate your existing state to Do you want to copy existing state to the new backend in node_modules/cdktf-cli/bundle/bin/cmds/handlers.js.
Anything Else?
No response
References
A possible reason for this is that the migrateState flag is not being passed when the diff handler initialises terraform here:
3.Run`cdktfdiff<stackname> --migrate-state` to migrate the state into HCP Terraform or Terraform Enterprise.
Help Wanted
I'm interested in contributing a fix myself
Community Note
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
If you are interested in working on this issue or have submitted a pull request, please leave a comment
The text was updated successfully, but these errors were encountered:
Expected Behavior
cdktf cli should trigger a state migration to the terraform process
Actual Behavior
Terraform fails to initialise and shows the following error:
Steps to Reproduce
cdktf diff --migrate-state
Versions
language: ts
"cdktf": "^0.20.
"cdktf-cli": "^0.20.8",
"constructs": "^10.3.0"
Terraform/1.5.7
Providers
hashicorp/google-beta@~> 5.41
Gist
Can't migrate state to a different backend.
Possible Solutions
No response
Workarounds
Manually editing
node_modules/cdktf-cli/bundle/bin/cmds/handlers.js
:migrateState:this.options.migrateState
tomigrateState:true
;,e.migrateState&&r.push("-migrate-state")
next toe.noColor&&r.push("-no-color")
and before the;
;Workaround for a possibly separate issue of migrating the state (see #3704 (comment)):
Should Terraform migrate your existing state
toDo you want to copy existing state to the new backend
innode_modules/cdktf-cli/bundle/bin/cmds/handlers.js
.Anything Else?
No response
References
A possible reason for this is that the
migrateState
flag is not being passed when thediff
handler initialises terraform here:terraform-cdk/packages/@cdktf/cli-core/src/lib/cdktf-project.ts
Line 400 in 4f8c0c9
The method
getStackExecutor
accepts a second argument with the cli options, which are spread here:terraform-cdk/packages/@cdktf/cli-core/src/lib/cdktf-project.ts
Line 333 in 4f8c0c9
terraform-cdk/packages/@cdktf/cli-core/src/lib/cdktf-stack.ts
Line 261 in 4f8c0c9
The value of
this.options.migrateState
isundefined
at that time.Not only that, but it seems the terraform cli package is also not passing the
-migrate-state
to the terraform process:terraform-cdk/packages/@cdktf/cli-core/src/lib/models/terraform-cli.ts
Line 123 in 4f8c0c9
Relevant docs:
terraform-cdk/website/docs/cdktf/concepts/remote-backends.mdx
Line 348 in 4f8c0c9
Help Wanted
Community Note
The text was updated successfully, but these errors were encountered: