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

Does not use argument's default value when null is passed #27730

Closed
stigok opened this issue Feb 10, 2021 · 2 comments
Closed

Does not use argument's default value when null is passed #27730

stigok opened this issue Feb 10, 2021 · 2 comments
Labels
bug new new issue not yet triaged

Comments

@stigok
Copy link

stigok commented Feb 10, 2021

Terraform Version

Terraform v0.14.6
+ provider registry.terraform.io/hashicorp/null v3.0.0
+ provider registry.terraform.io/hashicorp/random v3.0.1

Terraform Configuration Files

https://github.com/stigok/terraform-use-default-value-when-null

Debug Output

https://raw.githubusercontent.com/stigok/terraform-use-default-value-when-null/main/tfdebug.log

Crash Output

Expected Behavior

The modules/test module should use the module's default value for my_var when it is passed a null value, as stated in the Terraform syntax documentation:

null: a value that represents absence or omission. If you set an argument of a resource or module to null, Terraform behaves as though you had completely omitted it — it will use the argument's default value if it has one, or raise an error if the argument is mandatory. null is most useful in conditional expressions, so you can dynamically omit an argument if a condition isn't met.

Actual Behavior

my_var in the resource definition is not ignored as if it was ommited, but passed as an acutal null value, which in this example breaks string interpolation.

Steps to Reproduce

  1. terraform init
  2. terraform plan

Additional Context

Linux 64bit

References

Somewhat related to #5471

@stigok stigok added bug new new issue not yet triaged labels Feb 10, 2021
@jbardin
Copy link
Member

jbardin commented Feb 10, 2021

Thanks @stigok

We're tracking this in #24142

@jbardin jbardin closed this as completed Feb 10, 2021
@ghost
Copy link

ghost commented Mar 13, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants