-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
fix: Use coalesce
when desired default value is not null
#2696
Conversation
Co-authored-by: Bryant Biggs <bryantbiggs@gmail.com>
try
to coalesce
when desired default value is not null
coalesce
when desired default value is not null
coalesce
when desired default value is not null
coalesce
when desired default value is not null
main.tf
Outdated
@@ -386,7 +386,7 @@ resource "aws_eks_addon" "this" { | |||
cluster_name = aws_eks_cluster.this[0].name | |||
addon_name = try(each.value.name, each.key) | |||
|
|||
addon_version = try(each.value.addon_version, data.aws_eks_addon_version.this[each.key].version) | |||
addon_version = coalesce(try(each.value.addon_version, null), data.aws_eks_addon_version.this[each.key].version)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my apologies, I gave you one too many parenthesis:
addon_version = coalesce(try(each.value.addon_version, null), data.aws_eks_addon_version.this[each.key].version)) | |
addon_version = coalesce(try(each.value.addon_version, null), data.aws_eks_addon_version.this[each.key].version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed! Thanks for the fix and sorry for the delay, I was disconnected these past days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!
### [19.15.4](v19.15.3...v19.15.4) (2023-07-27) ### Bug Fixes * Use `coalesce` when desired default value is not `null` ([#2696](#2696)) ([c86f8d4](c86f8d4))
This PR is included in version 19.15.4 🎉 |
I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
First of all, thanks for the work on this module. We've been using it for a couple of years now ❤️
Description
Use
coalesce
when the desired default value of an expression is notnull
.Motivation and Context
We maintain an opinionated wrapper module around this one where we used to install the EKS add-ons using their separate Terraform resources but eventually switched to doing it through this module since it supports it.
On our module, we would like to support providing add-on versions while still keeping the default behavior from this module of retrieving the matching version from a data_source if no version is provided.
This would be a snippet from our module.
But since
null
is a valid expression when using thetry
function;try(each.value.addon_version, data.aws_eks_addon_version.this[each.key].version)
is returningnull
instead of defaulting to use the version from the data_source as we would like.Using coalesce instead should fix this.
As a workaround, we could re-implement the same logic for retrieving add-on versions from data sources in our wrapper module or maybe use dynamic blocks, but if you don't see anything wrong with this change it would simplify our module a bit.
Breaking Changes
This might be be considered a breaking change since it would change the behavior for end users that are explicitly passing
null
as input variable to the module, but it probably won't affect many users.How Has This Been Tested?
After an upgrade from EKS 1.25 to EKS 1.26 with this input:
plan with
try
:plan with
coalesce
:I hope I've made myself clear 😛. Let me know your thoughts and if you are OK with this change. And if you wish I can extend it to all
try
occurrences wherenull
is not the desired default value.