You can use terraform filebase64() function to read the content of a file in base64. filebase64() reads the contents of a file at the given path and returns them as a base64-encoded string.
Syntax: filebase64(file_path)
Example:
1 2 3 4 5 6 7 8 9 |
## create a file with some content echo 'locals { name = "debjeet" }' > main.tf ## Open terraform console terraform console ## Get the content of a file filebase64("main.tf") ## returns "bG9jYWxzIHsgbmFtZSA9ICJkZWJqZWV0IiB9Cg==" |