Reading the file content from terraform configuration file /tfconfig

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
|-- terragrunt.hcl
`-- 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 line 21, in provider “vault”:
21: token = file("/tfconfig/vault_hmac_token.txt")

Call to function “file” failed: no file exists at

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 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

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 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.