Hi All,
I am looking out for help/suggestion on how to read the content of a file from /tfconfig configuration path. My current directory has the following file structure
Current directory is /tfconfig
Contents of /tfconfig
/tfconfig
|-- main.tf
|-- terraform.tf
|-- terragrunt.hcl
|-- variables.tf
`-- vault-hmac-token.txt
Now when I am trying to read the .txt file using the file function, it is not able to identify.
Error: Error in the function call
on main.tf line 21, in provider “vault”:
21: token = file("/tfconfig/vault_hmac_token.txt")
Call to function “file” failed: no file exists at
tfconfig/vault_hmac_token.txt.
Open to suggestions on how can i resolve this.
You can refer to the module directory using path.module
. For example:
token = file("${path.module}/vault_hmac_token.txt")
Now even though the file not exists issue is resolved, i started noticing a new error.
on main.tf line 21, in provider “vault”:
21: token = base64decode("${path.module}/tfconfig/vault-hmac-token.txt")
|----------------
| path.module is “.”
Call to function “base64decode” failed: failed to decode base64 data
‘./tfconfig/vault-hmac-token.txt’.
Any suggestions here on why this behavior?
Also can someone confirm if this is the correct way to read the value and decrypt.
token = “${base64decode(filebase64(“vault-hmac-token.txt”)}”
Error: Missing argument separator
on main.tf line 22, in provider “vault”:
22: token = “${base64decode(filebase64(“vault-hmac-token.txt”)}”
A comma is required to separate each function argument from the next.