Add terraform state registry#36710
Conversation
I think it's out of scope - if the feature doesn't work, terraform state isn't the place to check that
|
What's keeping it a WIP PR? |
|
The fact it's a messy merge of the two linked ones, the fact I haven't read the code properly and just removed failing parts and the fact I'm not sure it works properly aside from simple tests (for example if locking works as it should). Reviews are welcome but I don't want to advertise this as ready for merge/review if I don't know it is. |
|
@elbandi In case you're still around and interested in the topic, maybe you could you take a look? It's mostly based on your work which was in way better state than the other one (plus the other one is stale) unless you want to resume working on your version or take this one back. |
This serial based versioning is not good. terraform state has only one version: the latest. Old states are obsolete. But we want to store different states on one project: eg branch or different input variables. like in gitlab: |
|
Makes sense but in that case why does gitlab have |
Looks like, in gitlab you can only download and delete the old states. (maybe for audit?, i dont know what is it good for in normal circumstances). But upload/lock/unlock based on state-name, UI hasn't got version control too. |
rework tests for better coverage and defined behavior
|
So finally it catches 1.26 release. |
|
Spoke too soon. Found a bug with encrypted state handling... I'll fix that and add it to tests so it's also covered. It's fairly simple, it just decodes the state wrong |
…ed state test for encrypted state was added
|
Fixed. Dropped some validation rules which weren't that useful in the first place. I really don't expect anyone to actively push state files via curl with only two properties and even if I can reintroduce it if needed via a patch. |
|
@TheFox0x7 did you create a pr for docs? |
|
It's in PR description - https://gitea.com/gitea/docs/pulls/357 |
* main: Repair duration display for bad stopped timestamps (go-gitea#37121) Add terraform state registry (go-gitea#36710) Add placeholder content for empty content page (go-gitea#37114) Improve control char rendering and escape button styling (go-gitea#37094) Add gpg signing for merge rebase and update by rebase (go-gitea#36701) Move package settings to package instead of being tied to version (go-gitea#37026) Merge some standalone Vite entries into index.js (go-gitea#37085) Update Nix flake (go-gitea#37110) [skip ci] Updated translations via Crowdin Fix the wrong push commits in the pull request when force push (go-gitea#36914)
|
This PR still lacks the ability to store more state files for one "package". I will try to rebase my code to this. |
|
I'd argue that it makes little sense to store different states in the same package. If you can add different suffix to the name, you can have them in separate packages - why keep them in a single one? What's the usecase? I'm not entirely against the idea of having the states user named instead of generic "tfstate", but it does complicate the UI side of locks as they now would have to list each state lock individually for the state in the package. Backend is less of an issue as you could just add a state name suffix to the tflock name of the lock record. |
As i said: same terraform code with different envs. (devel, stage, prod). The difference only the input tfvars (=provider auth, setting params, like ip address, dns names, etc), but resources are same. If we want to add separete envs for every developers, the number of state packages are grows fast (N project * M developers) |
|
Maybe you can open a proposal issue with real examples (detailed config, commands, etc), then it would be very useful to help people to understand the problem in real world and discuss the design. By the way, if we would come to a conclusion that "same terraform code with different envs" is a must and it is a breaking change (hopefully not), we can even spend more time on it to make it right before 1.26.0. |
|
okay I dug for a bit and I have a good enough reason to nack this, sorry. |
Adds terraform/opentofu state registry with locking
implements: #33644
Based mostly on: #34331 as it was in more complete state (it didn't error out on apply) and somewhat on: #33277
I also checked encrypted state, it works out of the box.
Docs PR: https://gitea.com/gitea/docs/pulls/357