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

Remote backend support encryption for all #31013

Open
DblK opened this issue May 6, 2022 · 2 comments
Open

Remote backend support encryption for all #31013

DblK opened this issue May 6, 2022 · 2 comments
Labels
enhancement new new issue not yet triaged

Comments

@DblK
Copy link

DblK commented May 6, 2022

Current Terraform Version

Terraform v1.1.9
on darwin_amd64

Use-cases

I use terraform to spawn my infrastructure and there are some data that are simple text in the state and can be credentials or other secrets.
I wanted to have all sensitive information not displayed in cli (use of sensitive property on output) but also in the state and still being usable!

Attempted Solutions

One approach could be to use remote backend but not all backend supports encryption and especially local which is the default one.
This reduce the choices to where to store state based on encryption criteria.

Proposal

It would be great to add options to encrypt state entirely or partially (sensitive output) by adding parameters to remote_backend regardless the backend chosen.

Something like this

data "terraform_remote_state" "foo" {
  backend = "gcs/local/whatever"
  config = {
    # Specific properties (here gcs example)
    bucket  = "terraform-state"
    prefix  = "prod"

    # Generic properties
    encrypt_state = true
    encrypt_privateKey = "..."
    encrypt_publicKey = "..."
  }
}

This will also solve the Security Notice on tls_private_key while encrypting state file and so generated private keys.

References

Not found

@DblK DblK added enhancement new new issue not yet triaged labels May 6, 2022
@apparentlymart
Copy link
Contributor

apparentlymart commented May 9, 2022

Hi @DblK! Thanks for sharing this use-case.

I think you might be proposing something similar here to what I proposed in #9556. This is an example of an awkward genre of issue where I opened it before I was employed by HashiCorp and so it's a proposal on behalf of my old employer 😬 but I think it has similar underlying motivations, even though the details are a bit different.

The main blocking design questions across all of these variations of "storing sensitive data in the state" proposals is what Terraform ought to do in situations where you don't have the key. In this particular variant where the entire state is encrypted together, the terraform_remote_state data source effectively becomes useless unless you broadly distribute your private key, which I think most would consider unacceptable from a threat modelling standpoint.

Other variants call for encrypting different subsets of the state data which can therefore potentially allow some use of Terraform in situations where the key isn't known, but it's not clear yet what the right tradeoff is.

For now, the advice (which you've already seen) is to select a storage backend which supports encryption itself if you intend to store sensitive values in state. That has its own drawbacks -- it means anyone with access to the credentials needed to talk to the backend always has access to the entire state, as above -- but those problems effectively exist outside of Terraform rather than inside it, and so can be addressed (in part) with techniques such as short-lived credentials.

@kayrus
Copy link
Contributor

kayrus commented May 19, 2022

@apparentlymart from my understanding, implementing the pluggable backends would allow to fix sensitive values at the first place: #5877

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants