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

Prevent duplicate affected entities in non org mode #79

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mskouba
Copy link

@mskouba mskouba commented Apr 19, 2024

The Issue:
Currently when not using org mode AHA will report duplicate affected entities when an event has a high number of impacted entities. This is due to the get_health_accounts function returning a list with an account ID appended for each iteration of the describe_affected_entities paginator, resulting in a list of the same single account ID repeated several times.

The get_affected_entities function then takes this list of duplicate account IDs (since in non org mode there is only one account being polled) and adds the same affected entities for each item in the list.

The Proposed Solution:
The updated code reworks the get_affected_entities function so that it better handles both org mode and non org mode by having the for loop over the impacted accounts run only for org mode and making the affected_accounts parameter optional so that it does not need to be passed when in non org mode.

The describe_events function now does not need to call get_health_accounts and only calls get_affected_entities, which has the added benefit of removing a redundant call to describe the affected entities. It also deletes the get_health_accounts function altogether as it is no longer needed anywhere in the lambda. The affected_accounts variable is populated once the affected entities are pulled by pulling it from the first entity in the affected_entities list so that it can still be added to the DynamoDB item.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant