-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Can not set variable to null in Terragrunt inputs #892
Comments
Did a quick test, @yorinasub17. If the variable is defined as a If the variable is defined as a |
This may be a limitation of terraform. I think if you run |
I just ran into this same issue where I have some conditional code around null string variable handling to create a resource. Passing null from terragrunt.hcl negates the null handling, though when omitting the variable from inputs in terragrunt.hcl, null handling works as expected. |
I have faced this problem today as well. |
Hello all,
output:
I've just submitted a fix in the pull request 1367 (with option for old behavior) |
Same problem , trying to pass null to input for certain environments |
You can use this approach to sort out the null approach avoiding to pass null values to the inputs (if you are using default values inputs in your modules, else it would fail)
Thanks @yorinasub17 for this tip! |
Looks like I faced the same issue: include "envcommon" {
path = "${dirname(find_in_parent_folders())}/_envcommon/prod/rds/alpha/terragrunt.hcl"
merge_strategy = "deep"
}
dependency "rds-alpha-master" {
config_path = "${get_terragrunt_dir()}/../../../../eu-north-1/prod/rds/alpha"
}
inputs = {
cross_region_replica = true
replicate_source_db = dependency.rds-alpha-master.outputs.db_instance_arn
# Username and password should not be set for replicas
username = null
password = null
multi_az = false In rendered json I can see:
And then I get:
|
The problem has been relevant for three years, it seems they are not going to solve it, have there been any crutches or workarounds?
|
Try generating a tfvars file that sets the variable to null? |
I have just hit this problem with a few variables that my module has defaults for. But they all turn out to be set to the string "null" in the state. Is there no traction on this after 3 years? Or is there another workaround like a conditional to leave the variable out from the inputs? |
I noticed that it got I hope that it will be fixed asap so I don't need to make a validation or condition in very variable |
Just had this issue too, what are people using as a workaround? |
wow, got this issue today. A big limitation. |
Also faced this problem. |
We're running into this problem as well. Edit: Creating a |
@denis256 @yorinasub17 |
Just faced this issue today |
This is indeed rather ugly and limiting. I would like to not have to have a specific check for "null" strings. |
Faced this today, big limitation in Terragrunt IMO. |
I ran into this today. This is implicit type coercion, and it would help to produce at least a warning message until passing nulls to inputs is supported. |
Hello everyone, quick update on this issue. This is indeed a limitation of terraform. The variable loader for environment variables and Until then, there are a few workarounds mentioned in this issue. Alternately, if you have control of the module you are trying to use the terraform team suggested the following workaround: Set the type constraint for the variable to type = any, which tells Terraform to expect a value of any type, and then use a custom validation rule to restore the constraint that it must be something stringable:
You'd then be able to set the environment variable either to a literal string expression or to null:
Terragrunt directly translates your inputs into TF_VAR_ statements. The examples above would translate to:
|
Hello @denis256, thank you for the update. Just fetched the latest version of Terragrunt for our project and saw that terragrunt init now always generates an empty .terragrunt-null-vars.auto.tfvars.json file in the repository even though we are only using hcl configs for our projects without empty inputs. Is there an option to deactivate the generation of the file with the help of a cli-flag or configuration similar to the skip_region_validation when generating the provider block? |
Hello, |
that's the question, right? I started having that file show up with just |
Hello @denis256, no immediate issue for the execution of the code but it would be nice if the generation could be skipped as described in #2670 so that not every terragrunt project in the future has to generate or ignore this file in the repository when there is no need for it in case of being empty. |
I am confused with this workaround... Isn't it the case that it is not possible to use single quotes in terragrunt to define strings? Isn't it the case that environment variables set externally of terragrunt, are not picked up by terraform? |
This needs investigation, but we were seeing some behavior where if you try to use
null
as one of the variable values ininputs
, terragrunt translates it as the string"null"
by the time it gets to terraform.The text was updated successfully, but these errors were encountered: