Create a Native State Backend
mackenbach opened this issue · 1 comments
We're currently using the secrethub-http-proxy as an HTTP state backend now, but preferably we'd like to write a custom state backend.
However, seeing as state backends aren't pluggable yet we will have to create a fork of the Terraform project and add our state there. For people to actually be able to use the backend though, we'd have to get it merged back into the Terraform project and included in the next release.
If you want us to push this native backend through, please take a moment to +1 👍 this issue and we'll prioritize it on the roadmap.
Implementation details
Technically speaking, it shouldn't be too difficult a task:
- Add a folder
backend/remote-state/secrethub
: https://github.com/hashicorp/terraform/tree/master/backend/remote-state - Implement the
backend.Backend
interface. For inspiration, check out the S3 and HTTP implementations: - Looking at the patterns other backends use, we would then create a small wrapper around the
secrethub-go/pkg/secrethub.Client
interface that implements the Terraform specific logic, similar to thehttpClient
type and have oursecrethub.Backend
type use that. - Most of the thinking for what the code should do in the
Get
,Update
,Delete
functions is actually already done in the proxy for the HTTPGET
,UPDATE
, andDELETE
handler functions. - Submit a PR and bob's your uncle 🎉
secrethub/secrethub-cli#285 contains a MVP of shipping a Terraform state backend with the SecretHub CLI.