terragrunt-atlantis-config icon indicating copy to clipboard operation
terragrunt-atlantis-config copied to clipboard

Missing Environment Variables

Open tide-jamiegwatkin opened this issue 1 year ago • 2 comments

We're testing terragrunt-atlantis-config with the intention of using it with Atlantis but am having a strange issue where ENV vars are not being found.

When running terragrunt-atlantis-config generate --output atlantis.yaml --autoplan --parallel --root core/eks_main/, terragrunt-atlantis-config fails to find any environment variable that has been defined in terragrunt.hcl.

The error outputted is:

[root@ terraform]$ terragrunt-atlantis-config generate --output atlantis.yaml --autoplan --parallel --root core/eks_main/
ERRO[0000] Error: Error in function call
      
ERRO[0000]   on /terraform/core/terragrunt.hcl line 3, in locals: 
ERRO[0000]    3:   environment       = get_env("OP_TF_ENV") 
ERRO[0000]                                              
ERRO[0000] Call to function "get_env" failed: EnvVarNotFound: Required environment variable OP_TF_ENV - not found.
 
ERRO[0000] Encountered error while evaluating locals.   
ERRO[0000] Error: Error in function call
      
ERRO[0000]   on /terraform/core/terragrunt.hcl line 3, in locals: 
ERRO[0000]    3:   environment       = get_env("OP_TF_ENV") 
ERRO[0000]                                              
ERRO[0000] Call to function "get_env" failed: EnvVarNotFound: Required environment variable OP_TF_ENV - not found.
 
ERRO[0000] Encountered error while evaluating locals.   
ERRO[0000] Error: Error in function call
      
ERRO[0000]   on /terraform/core/terragrunt.hcl line 4, in locals: 
ERRO[0000]    4:   application       = get_env("OP_TF_APP") 

When eching the env vars in the shell I'm able to see them all e.g:

[root@ terraform]$ env | grep OP_TF_ENV
OP_TF_ENV=test

The locals defined in /terraform/core/terragrunt.hcl look like this:

locals {
  ...
  environment       = get_env("OP_TF_ENV")
  application       = get_env("OP_TF_APP")
  country           = get_env("OP_TF_COUNTRY")
  root_folder       = get_env("OP_TF_ROOT_DIR")
  production_access = get_env("OP_PRODUCTION_ACCESS", "yes")
...
}

core/eks_main/terragrunt.hcl looks like:

terraform {
  source = ".//."
}

include "root" {
  path = find_in_parent_folders()
}

dependencies {
  paths = [
    "../other_resources"
  ]
}

Am I doing something wrong with this configuration?

tide-jamiegwatkin avatar Nov 07 '22 16:11 tide-jamiegwatkin