A simple encrypt program to be used by terraform's external data provider or as a CLI tool.
There are several commands which you can invoke on terraform-encrypt.
To encrypt a file in-place (or to another file) you run:
terraform-encrypt encrypt [sourceFiles...] [flags]
Flags:
-o
,--output string
: The target file location. Can only be used if a single file is passed. Specify '-' to output to stdout.-p
,--password string
: The vault password. This defaults to the value of environment variableVAULT_PASSWORD
.
To decrypt a file you run:
terraform-encrypt decrypt [sourceFiles...] [flags]
Flags:
-c
,--confirm-password
: Confirm the vault password when prompting.-o
,--output string
: The target file location. Can only be used if a single file is passed. Specify '-' to output to stdout.-p
,--password string
: The vault password. This defaults to the value of environment variableVAULT_PASSWORD
.
Create a json file:
{
"fieldA": "Value",
"message": "I am super secret!"
}
Encrypt the file:
terraform-encrypt encrypt secret.json
Read using terraform:
data "external" "secret" {
program = [
"terraform-encrypt",
"decrypt",
"${path.module}/path/to/encrypted/file",
"--output",
"-"
]
}
output "result" {
value = "${data.external.secret.result.message}"
}