Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Environment Variables #259

Open
tide-jamiegwatkin opened this issue Nov 7, 2022 · 2 comments
Open

Missing Environment Variables #259

tide-jamiegwatkin opened this issue Nov 7, 2022 · 2 comments

Comments

@tide-jamiegwatkin
Copy link

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?

@d4n13lbc
Copy link

Hi, I had the same issue and I moved my env vars from the locals section to the inputs section and it is working well now

@carlosz22
Copy link

Hi. I'm having exactly the same issue. I would prefer not to reorganize all environment variables because it means a huge effort. Why doesn't it fail in inputs and it fails in locals?

terragrunt-atlantis-config version 1.16.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants