-
Notifications
You must be signed in to change notification settings - Fork 6
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: Add opt-in config to create order independent log filters #78
fix: Add opt-in config to create order independent log filters #78
Conversation
Thanks for opening this PR @aburgel. We'll take a look and get back to you soon. As you pointed out, we have to be a little careful as they could be considered a breaking change. |
Hi @aburgel - thanks again for opening this PR. While we like what you've done, we are a little concerned changing the output behaviour as someone may be using it and changing from index based to a map of filter names could be problematic. Would you be open to adding an opt-in flag to enable the new, deterministic behaviour? The default behaviour would be to use the index approach. |
@MikeGoldsmith Thanks for the feedback. A flag sounds like a good way forward. I will add that in the next few 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.
Looks great, thanks @aburgel. I think we can revert the changes to the old aws_cloudwatch_log_subscription_filter
block but otherwise good.
@MikeGoldsmith thanks for the review and approval! will you hit the merge button and cut a release? with the failing check, merge is disabled for me. |
Yep, just needed to do some additional testing. Thanks again @aburgel. |
## Which problem is this PR solving? Fix a formatting issue from #78 that wasn't picked up on the PR but caused the main build to fail. ## Short description of the changes - Remove white space so the formatting passes validation
Which problem is this PR solving?
The cloudwatch-logs module accepts a list of log group names. It uses terraform's count meta argument to create a list of subscription filter resources, which makes the resources dependent on the order of the log group names input.
Adding and removing log group names can cause terraform to create and destroy resources for all log groups after the changed elements in the list. This is troublesome if you dynamically generate the list of log groups (e.g. by using
aws_cloudwatch_log_groups
data source), because your plan can have quite a lot of changes, even if you're only adding or removing a small number of log groups.Short description of the changes
Added an opt-in configuration option that uses
for_each
using the log filter names to create an order independent list of filters. When the list changes and the filter name is used, only differences in the existing and updated list of filters are modified.How to verify that this has the expected result
I ran plan using this branch on my terraform project, and it resulted in the following: