Skip to content

Commit 3a254ef

Browse files
Terraform variables via .env file
1 parent 80c51bf commit 3a254ef

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

devops/terraform/variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SOURCE: https://stackoverflow.com/a/76194380/15454191
2+
locals {
3+
dot_env_file_path = "./.env"
4+
dot_env_regex = "(?m:^\\s*([^#\\s]\\S*)\\s*=\\s*[\"']?(.*[^\"'\\s])[\"']?\\s*$)"
5+
dot_env = { for tuple in regexall(local.dot_env_regex, file(local.dot_env_file_path)) : tuple[0] => sensitive(tuple[1]) }
6+
api_token = local.dot_env["API_TOKEN"]
7+
}

0 commit comments

Comments
 (0)