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

Support custom permissions mask for local state files #34949

Open
gmarciani opened this issue Apr 5, 2024 · 3 comments
Open

Support custom permissions mask for local state files #34949

gmarciani opened this issue Apr 5, 2024 · 3 comments
Labels
enhancement new new issue not yet triaged waiting-response An issue/pull request is waiting for a response from the community

Comments

@gmarciani
Copy link

Terraform Version

Terraform v1.7.4
on darwin_arm64

Use Cases

As a Terraform user I want my state files containing sensitive information (eg: TLS key secrets) to be secured without being forced to upload them to a remote endpoint/bucket.

Attempted Solutions

The local backend does not provide a way to configure the permissions mask of the state files.
See https://developer.hashicorp.com/terraform/language/settings/backends/local

Proposal

Add a new attribute permissions to the local backend, accepting POSIX permissions mask.

Example:

terraform {
  backend "local" {
    path = "relative/path/to/terraform.tfstate"
    permissions = "600"
  }
}

References

No response

@gmarciani gmarciani added enhancement new new issue not yet triaged labels Apr 5, 2024
@crw
Copy link
Collaborator

crw commented Apr 5, 2024

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!

@apparentlymart
Copy link
Member

Hi @gmarciani,

Today's Terraform respects the process umask when creating a state file on local disk. Therefore you can control the permissions of this and all other files that Terraform creates by changing the umask to 077 before you run Terraform.

For example:

$ umask 077
$ terraform apply
$ ls -lah
total 12K
drwx------   2 mart mart 4.0K Apr  8 11:36 .
drwxrwxr-x 139 mart mart 4.0K Apr  8 11:35 ..
-rw-r--r--   1 mart mart    0 Apr  8 11:35 example.tf
-rw-------   1 mart mart  180 Apr  8 11:36 terraform.tfstate

@crw crw added the waiting-response An issue/pull request is waiting for a response from the community label Apr 10, 2024
@crw
Copy link
Collaborator

crw commented Apr 10, 2024

@gmarciani Does the above comment satisfy your use case? If so I'll close this issue, if not I will leave it open. Thanks!

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 waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

No branches or pull requests

3 participants