-
Notifications
You must be signed in to change notification settings - Fork 568
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
Replace try()
with lookup()
where possible
#227
Comments
try()
with lookup()
where possible
If no one is currently working on this, I could take this on. I don't want to just start doing stuff on my own if someone has already started to work on this 😊 |
@roberthstrand... No-one working on this yet from our side so if you'd like to contribute that would be awesome. Just be aware that there are still a lot of legitimate cases where we will still need to use We could probably remove these completely as a stretch goal, but would require building up the objects in layers using tertiaries. |
@roberthstrand - just a heads up that I am partially covering this as part of an upcoming update. The files I will be resolving include the following:
|
I went on Christmas vacation and forgot all about this. I will look over the next version and see what remains, thanks for letting me know. |
Upon further investigation and testing, care needs to be taken when using ╷
│ Error: Invalid function argument
│
│ on ..\..\..\main.tf line 49, in module "management_resources":
│ 49: custom_settings_by_resource_type = lookup(local.management_resources_advanced, "custom_settings_by_resource_type", local.empty_map)
│ ├────────────────
│ │ local.empty_map is object with no attributes
│
│ Invalid value for "default" parameter: the default value must have the same type as the map elements.
╵ Workaround needed before this can be successfully implemented. |
Workaround for the above... if you want an I could have done this with actual expected keys with default values, so merge overrides the values, but it felt like a more generic approach would avoid confusion and make the base object generic. |
Trigger ADO Sync |
* Add logic to map automation account to region * Replace `try` with `lookup` as per #227
Trigger ADO Sync |
Closing this issue as this is now considered a coding standard for this module and will be addressed over time as code is refactored. |
Within the module we make regular use of the
try()
function to allow optional fields to be gracefully skipped when not present in the input variable.A side-effect of this is a lot of noise in the verbose logging, but this is possibly not the most efficient function to use.
To reduce the impact of this and provide more logical handling of scenarios where the base object exists, but a specific
key
may or may not exist, thelookup()
function would make more sense.The text was updated successfully, but these errors were encountered: