-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Feature: Eventbridge v2: Add tagging #10840
Conversation
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 1h 39m 6s ⏱️ -12s Results for commit 8628c6f. ± Comparison against base commit 179a8e3. This pull request removes 1 and adds 14 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
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 tests are quite comprehensive. Nice coverage 👍
My main question is whether it would be feasible to reuse the tagging service (maybe not because the resource type differentiation is too specific)?
I added some suggestions to simplify the code and resolve potential smaller bugs.
localstack/services/events/models.py
Outdated
|
||
class EventsStore(BaseStore): | ||
# Map of eventbus names to eventbus objects. The name MUST be unique per account and region (works with AccountRegionBundle) | ||
event_buses: EventBusDict = LocalAttribute(default=dict) | ||
|
||
# Maps resource ARN to tags | ||
TAGS: TagDict = CrossRegionAttribute(default=dict) |
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.
We have a TaggingService
that implements tagging transparently (noticed by looking into DMS models as one of our new implementations). Is that applicable here or does different handling based on the resource type require a special case?
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.
used TaggingService in: df9b76c
The only issue I see is, that the pattern other services use is to store the TagginService objects in the store, which violates a bit of what we discussed a couple of weeks ago that data and functions should be strictly separated. This comes back to the issue that the AcountRegionBundle needs additional logic that handles this separation which would make a lot of providers cleaner.
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.
Very neat ✨
IMHO, that's a compromise worth taking vs. re-implementing the same thing for every service. The likelihood of a major change in tagging is very low.
store = self.get_store(context) | ||
resource_type = get_bus_or_rule(resource_arn) | ||
if not resource_type: | ||
pass # TODO handle error for tagging not rule or event_bus |
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.
any particular reason why we don't handle that? It looks like an easy case
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.
fixed in: bd3f9db
if "arn:aws:events" not in resource_arn_or_name: | ||
return resource_arn_or_name | ||
resource_type = get_bus_or_rule(resource_arn_or_name) | ||
# TODO how to deal with / in event bus name or rule name |
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.
This seems like a recurring theme (see #10789 (comment)). Can we get that fixed before we introduce this bug at too many different places?
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.
Not really, I do not have any approach to fixing this, and we seam to also assume in many other providers that names will not contain /
@@ -596,12 +688,21 @@ def _get_limited_dict_and_next_token( | |||
return limited_dict, next_token | |||
|
|||
def _extract_event_bus_name( |
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.
This method is getting increasingly complex. Could be a candidate for a unit test to cover edge cases easily (as long as we can ensure AWS parity).
bd3f9db
to
067d9a7
Compare
Motivation
Event bridge allows for adding tags to event buses and rules: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-tagging.html
This PR introduces the ability to create event buses and rules with tags, add and remove tags to existing buses or rules and list tags for buses and rules.
Changes
Use most widely used pattern of handling tags from multiple other services by extend store with TagDict mapping resource arn to the dictionary of tags.
Exten test suite to cover all different options of tagging.