Skip to content

Commit

Permalink
Don't override env vars user has already set
Browse files Browse the repository at this point in the history
  • Loading branch information
brikis98 committed Jun 7, 2019
1 parent 9857bbb commit fdce37c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,9 @@ TF_VAR_tags='{"Name":"example-app"}' \
terraform apply
```
Note that Terragrunt will respect any `TF_VAR_xxx` variables you've manually set in your environment, ensuring that
anything in `inputs` will NOT be override anything you've already set in your environment.
### AWS credentials
Expand Down
5 changes: 4 additions & 1 deletion cli/cli_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,10 @@ func setTerragruntInputsAsEnvVars(terragruntOptions *options.TerragruntOptions,
}

for key, value := range asEnvVars {
terragruntOptions.Env[key] = value
// Don't override any env vars the user has already set
if _, envVarAlreadySet := terragruntOptions.Env[key]; !envVarAlreadySet {
terragruntOptions.Env[key] = value
}
}

return nil
Expand Down

0 comments on commit fdce37c

Please sign in to comment.