-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Remote state management using git provider #16616
Comments
Hi @anujg! Thanks for this suggestion. I want to make sure I understand properly your suggestion: I think what you would like is for Terraform to make a commit and push to a remote git repository each time it needs to save a new version of the state. This would mean that each state update would have its own git commit. I assume you'd want to keep many states in the same repository, rather than having a separate repository per state, and so that would imply that Terraform must preserve all existing files in the tree when it writes a new state, and that it must be defensive against conflicts where two different concurrent Terraform runs try to commit and push at the same time. This would be a pretty different sort of backend than any of the others, due to git's decentralized model requiring a lot more state to be maintained client-side, so I don't expect we'd be able to work on such a thing for the foreseeable future, but it is an interesting idea so I'll leave this open here to remind us about it in the future. |
For me, just being able to use a single repository per state would be great. Git being decentralized by design means that you get locking for free. |
First, apologies if this is spammy. The company I work for had a similar need and I created an HTTP backend that, among other things, can keep your state file in a Git repo. There's still a lot I want to add to it, but we've been using it for managing our prod and non-prod environments for the last 4 or 5 months and it's been pretty stable for us. |
I don't think this is quite true... to stop someone else from pulling and working on state, wouldn't you have to make a commit to 'lock' the state, and then another one to 'unlock' it once you're done? You'd also need to pull before you lock and then have the lock fail if you couldn't push it back. If you run |
I haven't thought too much into it, but wouldn't one be able to pull changes on |
We could use this too. And what you describe seems too complicated. I would say for most people it would be enough to be able to specify a git url (http or ssh) to use for For example we already have all our terraform configurations in git. Whenever we update the state that automatically means a new commit. Making sure there are no conflicts (i.e. someone else doesn't try to use your state before you push your changes, if you are in the process of making them) goes under standard working with VCS routines and shouldn't be in Terraform's scope to handle. |
Thanks for sharing the use-case @megakoresh. It sounds like you're using Terraform in a non-standard way (state in version control alongside the configuration), but then finding that this means you lose the ability to retrieve another state using At present it's not possible to have a backend that only works with |
I wonder if a possible way to get some of the git/SCM features could be a totally separate non blocking cron that would check S3 backend (for example) for delta changes, and on changes, will pick them up and commit to git. |
You might be interested in this: https://github.com/plumber-cd/terraform-backend-git |
I really appreciate this proposal, and I think there's been healthy discussion. I'm going to close this issue for 3 reasons:
|
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. |
We need a feature to store the remote state of terraform using git as a backend store , apart from s3 buckets. This would be really helpful as it gives us an extra and probably more secure option than s3.
The text was updated successfully, but these errors were encountered: