Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

greater granularity on migrate-state approvals for CI / headless runs #31671

Open
novas0x2a opened this issue Aug 20, 2022 · 1 comment
Open

Comments

@novas0x2a
Copy link

novas0x2a commented Aug 20, 2022

Terraform Version

Terraform v1.1.9
on linux_amd64

but I've diff'd internal/command/meta_backend_migrate.go between 1.1.9 and main and there haven't been any relevant changes to the flow since then.

Use Cases

I'm trying to orchestrate a state migration via CI using init -migrate-state. The issue is:

  • In the simple case (empty destination state) I want to permit the migration in a headless fashion (like -force was passed, no input required)
  • In the complex case (non-empty destination state) I want the migration to fail; humans will need to resolve this before trying again.

Attempted Solutions

As far as I know there's no solution entirely within terraform. My current plan is to manually copy the state from the source to the destination, checking for and forbidding an overwrite, before calling terraform (in a normal fashion; TF won't know in this scenario that a migration happened).

Proposal

The most complex version of this might be to have some sort of generic functionality to agree to specific input prompts without agreeing to others; for example, if the prompt ID was split into backend-migrate-to-backend-empty and backend-migrate-to-backend-nonempty, and also if I could agree to specific prompts like -input=backend-migrate-to-backend-empty=true -input=false that would solve the problem in a really complete fashion.

The simplest version of this might be something like -migrate-state=if-empty or something like that.

References

I didn't find anything addressing this case.

@novas0x2a novas0x2a added enhancement new new issue not yet triaged labels Aug 20, 2022
@crw
Copy link
Collaborator

crw commented Aug 25, 2022

Thanks for this request!

@kmoe kmoe removed the new new issue not yet triaged label Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants