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

Docs: Provide some clarity with "terraform state mv" usage and remote states. #10481

Closed
dotspec opened this issue Dec 1, 2016 · 19 comments · Fixed by #15652
Closed

Docs: Provide some clarity with "terraform state mv" usage and remote states. #10481

dotspec opened this issue Dec 1, 2016 · 19 comments · Fixed by #15652
Assignees

Comments

@dotspec
Copy link

dotspec commented Dec 1, 2016

Hi there,

I started refactoring a bunch of terraform configs a couple days ago and found this to be a gigantic hole in the documentation for the command. I don't know if my situation was too special snowflake-y to be of use to others but thought I'd open an issue in case.

My specific case revolved around breaking up a single monolithic remote state into per-environment states. In order to make this work I needed to use the -state-out flag to target the new state but...wait what's this?

Path to the state file. Defaults to "terraform.tfstate". Ignored when remote state is used.

Then what's the proper thing to do here? I finally settled on disabling remote states for both files, performing the moves and then re-enabling and while it works it sure feels kludgy.

Even something as simple as including another usage example in the docs for moving between two states that aren't local would have been super helpful and saved me some pain. Or if remote states don't work with 'state mv' calling that out would be great.

Hopefully this stuff isn't too specific for general docs, and also that I just didn't miss some really basic usage and shamed myself by opening an issue.

@Gary-Armstrong
Copy link

@dotspec It's not just you. I came here for the same clarification. Would like to avoid de-remote-ing my state files for this operation.

@bdashrad
Copy link

When I did this previously, i had to disable remote state for both files. I was hoping that woudn't be the case anymore.

@gopisaba
Copy link

+1

9 similar comments
@urtens
Copy link

urtens commented Apr 6, 2017

+1

@aterreno
Copy link

aterreno commented Apr 6, 2017

+1

@lcostea
Copy link

lcostea commented Apr 23, 2017

+1

@fredsig
Copy link

fredsig commented Apr 26, 2017

+1

@heythisisnate
Copy link

+1

@liozN
Copy link

liozN commented Jul 3, 2017

+1

@kforsthoevel
Copy link

+1

@Wambosa
Copy link

Wambosa commented Jul 19, 2017

+1

@mathematician
Copy link
Contributor

+1

@Gary-Armstrong
Copy link

Gary-Armstrong commented Jul 21, 2017

Do I still have to de-remote my state files to mv resources between them?

Because:
The Terraform state subcommands all work with remote state just as if it was local state.

@nbering
Copy link

nbering commented Jul 21, 2017

@Gary-Armstrong I'm on v0.9.11 and can confirm that terraform state mv worked fine with the state in the s3 remote backend.

@Gary-Armstrong
Copy link

@nbering Thanks for the info. Did you mv from one state to another, or did you mv within a single state (rename)?

@nbering
Copy link

nbering commented Jul 21, 2017

@Gary-Armstrong Within a single state. I was just moving resources out of a submodule and into the root module.

@Gary-Armstrong
Copy link

Ah, I was really hoping someone had risked life and state to find a way to do this. :)
Until then, I am going to de-remote both states and use the documented local state commands.

@jbardin jbardin self-assigned this Jul 21, 2017
@jbardin
Copy link
Member

jbardin commented Jul 21, 2017

Hi Everyone,

This does need to be cleared up in the documentation. As it stands now, the state commands could only infer a single remote state which must be configured for init, and specify local files via flags because we don't have an addressing scheme to be able to specify multiple remote states in general.

If you want to work within a single state, the state commands should work with remote state (note that there may be a bug preventing this in the current 0.10rc). If you want to work with multiple states, you need to pull the states locally for the operations, and as always, it doesn't hurt to have extra backups.

We'll get the behavior finalized in an upcoming release, and update the documentation.

@ghost
Copy link

ghost commented Apr 8, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.