Is it safe to commit terraform.tfstate
to git?
#764
Replies: 2 comments
-
In general it's not recommended to commit the tfstate File to git. Of course for the security reasons you mentioned. But more for organizational reasons: the file represents the "real world" and thus there can only be one version of this file. It makes no sense to store it in git, since all users working with Terraform must have the same identical file. There is no strategy to merge different versions - there can't be different versions of the "real world". It is recommended to store this file in a central storage like S3 and ideally with encryption at rest, because of the sensitive information stored in there. Terraform supports this for example with a "s3" backend. And if you don't like to use Amazon services you can host a S3 instance yourself with MinIO. |
Beta Was this translation helpful? Give feedback.
-
@jr-dimedis We let terraform do its thing, the only thing we do is mark things like the Hetzner token as sensitive. I think @jr-dimedis comment is pretty accurate, probably best not to commit. Here's what GPT-4 has to say about this: Terraform's state file, Starting with Terraform 0.14, a new feature allows you to mark specific values in the configuration as being "sensitive", which will cause Terraform to redact that value from the CLI output. However, this doesn't affect the storage of these values in the state. However, you mentioned you are not seeing these secrets in your Here are some options for managing state files with sensitive data:
It's generally not recommended to commit your |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there, I have a couple of secrets which I use as sensitive variables in kube.tf
I found at terraform docs that even sensitive variables are output into
terraform.tfstate
.However inspecting it myself, I find none of the three.
Does someone know what is going on here with kube-hetzner and the respective security implications?
(From a maintenance perspective it would be great if the
terraform.tfstate
could be commited.)Beta Was this translation helpful? Give feedback.
All reactions