This repository was archived by the owner on Jan 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 459
Addresses an issue with logging configuration with improper for_each iterator #242
Open
dchernivetsky
wants to merge
5
commits into
hashicorp:master
Choose a base branch
from
dchernivetsky:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3ee2f5d
[n/a] revert the once
dchernivetsky 58427ef
[n/a] use can for proper bool
dchernivetsky 3fdd8d8
[n/a] missing paren
dchernivetsky 281d73b
[n/a] remove use of can
dchernivetsky a73e7bd
Update modules/vault-elb/main.tf
dchernivetsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Ah, I believe the approach we actually use is to call
lookuponvar.access_logsinstead ofxxx.value. That shouldn't require thecanusage...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.
Either
var.access_logsoraccess_logs.valueworks as we are iterating over a single item. As we're using thefor_eachmeta-argument it makes sense to use the iterator keys and values rather than referencingvar.access_logsdirectly.The use of
canis required whether you usevar.access_logsoraccess_logs.valueto ensure successful execution when you don't specify the optionalenabledargument as part of youraccess_logsdefinition.I've tested the solution as coded and it works in my implementation whether or not I choose to enable access logs.
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.
The 3-param version of
lookup(lookup(<MAP>, <KEY>, <DEFAULT>)) is what you want instead ofcan.NIT: It's true that using
access_logs.valueworks too, but it requires you scrolling up tofor_eachand parsing that to understand what that.valuecould be. That makes sense if we're looping over multiple items, but here, it's either 0 or 1, so usingvar.access_logsis more understandable.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.
Updated to remove the use of can. Appears to be working. However, it looks clunky. The idea behind can was to use it as a gate. It served a purpose of determining whether the user passed access_logs.enabled in the map. It is effectively optional param.
If the user passed this param, we would use it to determine whether to enable logs. If this param was not passed we would check the bucket param and assume that the user wants the logs enabled.
As is written right now, this logic wouldn't work, whether or not the enabled param is passed the code will default to looking at the bucket param.
I.e.
Would enable logging right now. Whereas beforehand it wouldn't enable logs (this is useful for controlling logs in lower envs)