-
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
GCloud backend #15592
GCloud backend #15592
Conversation
b20b905
to
dc15917
Compare
Hi @pbzdyl I contributed the legacy If this backend is accepted, I don't see any need to keep the existing I'll give this backend a try - thanks! |
👍 for this replacing the existing |
Hello @sl1pm4t , Thanks! Please, do share your feedback from testing this PR. If you have any suggestions for the PR's code, I would be happy to hear too as I am new to terraform and Go so I am sure there is something I could improve. I am not sure removing the current |
Hi @pbzdyl, thank you very much for your work! I was about to start working on implementing locking for the GCS backend when I stumbled into this PR. I'm quite interested in moving this along; are you still interested in working on this? I'd be happy to collaborate on this; I could e.g. send PRs against your feature branch if that's okay with you …? Best regards, |
Hello @octo, Yes - definitely. However, I am not sure if this PR will be accepted as there has been no feedback from Terraform team. What kind of changes would you like to add to this PR? Regards, |
@pbzdyl Great! Mostly coding style changes for now, but there are two noteworthy changes:
The changes are in the pr/15592 branch. I'll open a PR against your repo in a minute. Thanks and best regards, |
Hi, Sorry about the delayed response here, and thanks for the work you put into this! |
Hello @jbardin, Do you mean removing current |
Hi @jbardin, This PR adds support for named states, which are stored under a configurable directory. Previously, the gcs backend was using a state file. I think it should be possible to add backwards compatibility and rename this package to "gcs" so it can serve as a drop-in replacement. Do you know if another backend has implemented something similar so we can go for consistent behavior? Best regards, |
Hi @octo, I think the existing "remote-state" backends were all migrated from legacy remote state implementations, with azure being the most recent. S3 might be a good learning example, as it probably has the most "hacks" for legacy behavior, and is one of the more complex requiring S3 and DynamoDB in concert. |
Great, thanks @jbardin! |
Hi everybody! pbzdyl#2 has a lot of updates to this PR and should appear here once merged by @pbzdyl. How do you want to deal with the merge conflicts in vendor/? Should I rebase onto or merge the master branch? I can also remove the commit that changes vendor/ and we can do this as the last commit of the PR. Best regards, |
Hi @octo, Thanks for the update, I'll take a look ASAP. Don't worry if you can't get the vendor files to work out. If it turns into too much of a mess, I can transfer this whole PR into a branch here and fix them at the end. |
73cd4d7
to
4b7fd11
Compare
I have removed the commit updating vendor files and rebased on the latest master branch to resolve merge conflicts. I will try to update vendor files tomorrow. |
8dd7c42
to
64ad7d5
Compare
@jbardin, I was able to update vendor files. |
I was testing the new backend today and I noticed that we probably should add (ignored) @jbardin, @octo What would be the preferred way of handling it? Shall it be marked with Similarly, should |
I just tried the new code for the first time, and there are some small issues that need fixing:
I'll send patches for those issues soon. If you know a way to determine the terraform working directory (without having access to Best regards, |
This resurrects the previously documented but unused "project" option. This option is required to create buckets (so they are associated with the right cloud project) but not to access the buckets later on (because their names are globally unique).
…ent variable. This copies behavior from the Google Cloud provider.
This allows to select the region in which a bucket is created. This copies behavior from the Google Cloud provider.
This calls backend.TestBackend() and remote.TestRemoteLocks() for standardized acceptance tests. It removes custom listing tests since those are performed by backend.TestBackend(), too. Since each tests uses its own bucket, all tests can be run in parallel.
Enabling versioning without setting up lifecycle management leads to every lock file being archived, slowly accruing useless data.
This way tests clean up after themselves and don't leak buckets.
…ting. Since bucket names must be *globally* unique. By including the project ID in the bucket name we ensure that people don't step on each other's feet when testing.
@octo: Everything looks good to me, thanks for hanging in there! I'm going to hold off merging briefly, just until I can get some hands on testing with existing gcs remote states to try and catch any regressions. I do want to get that done ASAP though, so we don't start to lag behind and run into more merge conflicts, and can get this in before we start the process for the next major release. |
@jbardin Awesome, thank you! :) |
Hi @jbardin, is there any update? Is there anything I can help with to move this forward? Best regards, |
@octo: Thanks, just trying to schedule time to QA a build with this. It needs to be in before the beta process for 0.11 ;) |
moved this over to a branch where I could resolve the merge conflict asap. |
Thank you @octo - all the hard work was done by you! |
All, Can someone check the following bug that seems to be related to be this PR? |
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. |
Hello,
I have implemented a new backend: GCloud. It uses Google Storage for persisting state files and for distributed locks. It supports multiple workspaces.
Thanks to the authors of remote-state/consul and remote-state/s3 as I used their implementation as a basis for my code. Disclaimer: I am new to Go and Terraform, so please forgive me any dumbness in the code!
Features:
credentials
option, either file path to the JSON file or directly JSON contents)credentials
is not specified, uses Google Application Default CredentialsExample configuration:
Actual state file URL will be:
gs://${bucket}/${state_dir}/${workspace_name}.tfstate
and a lock file will be created at:
gc://${bucket}/${state_dir}/$workspace_name}.tflock
State locks use Google Cloud Storage Concurrency Control mechanism.
I am aware there is already the
gcs
backend. However, my understanding is that it is a legacy remote client implementation which doesn't support multiple workspaces. There would also be a risk of regressions potentially impacting deployments that use it.This is of course still work in progress as I am not sure if this PR would be accepted or not. If there is a chance it could be merged, I would complete the PR with tests, documentation updates and anything suggested by the reviewers.
Best regards,
Piotr