terraform
terraform copied to clipboard
Add `-auto-approve` to `init -migrate-state`
Terraform Version
Terraform v1.6.6
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v5.31.0
+ provider registry.terraform.io/hashicorp/local v2.4.1
+ provider registry.terraform.io/hashicorp/tls v4.0.5
Use Cases
To be able to provision the S3 backend bucket for my projects with the same configuration, chicken-and-egg problem, I came to a solution where I'm switching to and from the local backend using an override file, and migrate state between the two.
This is all wrapped in two bootstrap.sh and destroy.sh scripts that are run only once for project seeding and total annihilation, respectively.
This is working nicely, except that I can't make the state migration steps unattended, which gets quite annoying when dev requires running these in a loop. 😢
Attempted Solutions
Tried the -input=false, but this spits out an error
Proposal
Add an -auto-approve flag to the init command so -migrate-state can run unattended.
References
No response
Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!
Hey @silopolis,
can't you use --force-copy in your scenario? The force-copy is supposed to "suppress prompts about copying state data when initializing a new state backend. This is equivalent to providing a "yes" to all confirmation prompts", so it can used in combination with the migrate-state, e.g., terraform init -migrate-state -force-copy
@carminevassallo hi, thanks for the tip ! :pray:
Actually, I finally found that flag in the meantime, but that took some search, and yes, it does the job in my case. :) I left this issue open because I think it would make UI more consistent, but your explanation makes sense.