-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
add: TaggingService functionality to Lambda Provider #11745
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
Conversation
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 1h 20m 58s ⏱️ - 20m 42s Results for commit 4c00bab. ± Comparison against base commit 0338932. This pull request removes 930 and adds 5 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
e7e4c11
to
d598037
Compare
stored_tags = function.tags or {} | ||
stored_tags |= tags | ||
self._store_tags(function=function, tags=stored_tags) | ||
tag_svc_adapted_tags = [{"Key": key, "Value": value} for key, value in tags.items()] |
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 need to adapt the tags TaggingService
<-> LambdaProvider
when doing storage and retrieval of tags.
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.
It seems Lambda is doing something custom here (tag adaptation). Does it still make sense to use the TaggingService?
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.
I like the unified approach to tagging. Even though adapting in this way is a bit janky, I think the benefits of a single svc outweighs the costs of adapting to suit it.
In future, maybe we can extend the tag svc to better account for cases like this.
case "event-source-mapping": | ||
self._get_esm(resource_identifier, account_id, region) | ||
case "code-signing-config": | ||
raise NotImplementedError("Resource tagging on CSC not yet implemented.") |
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 haven't implemented tagging on Code SIgning Configuration as of yet, but we can easily extend the above to include it.
fn = self._get_function(function_name=fn_name, account_id=account_id, region=region) | ||
|
||
self._update_tags(fn, tags) | ||
if (resource_id := extract_resource_from_arn(resource)) and resource_id.startswith( |
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.
Unfortunately we need to run these dirty checks to ensure a Revision ID gets updated
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.
yeah, I see that we haven't found a good solution yet for dealing with the revision id updates in general 🤔
A small concern here is that the function and function version update are not synchronized with the tagging service, leading to potential race conditions (tag update and revision id updates not synchronized; quite unlikely, and consequences should be negligible). Would function locking via with function.lock
around the _store_tags prevent the race condition?
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.
Think we should rather look at improving this entire approach in a follow-up
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.
+1, good idea
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.
Great tagging test additions 💯
As discussed, it might be worth unifying the tags to avoid confusion and improve maintainability 🚀
fn = self._get_function(function_name=fn_name, account_id=account_id, region=region) | ||
|
||
self._update_tags(fn, tags) | ||
if (resource_id := extract_resource_from_arn(resource)) and resource_id.startswith( |
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.
yeah, I see that we haven't found a good solution yet for dealing with the revision id updates in general 🤔
A small concern here is that the function and function version update are not synchronized with the tagging service, leading to potential race conditions (tag update and revision id updates not synchronized; quite unlikely, and consequences should be negligible). Would function locking via with function.lock
around the _store_tags prevent the race condition?
stored_tags = function.tags or {} | ||
stored_tags |= tags | ||
self._store_tags(function=function, tags=stored_tags) | ||
tag_svc_adapted_tags = [{"Key": key, "Value": value} for key, value in tags.items()] |
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.
It seems Lambda is doing something custom here (tag adaptation). Does it still make sense to use the TaggingService?
function = self._get_function(name, account, region) | ||
with function.lock: | ||
function.tags = tags | ||
# dirty hack for changed revision id, should reevaluate model to prevent this: |
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.
style: yeah, this starts spreading like cancer 😅
maybe, we could consider extracting a helper method for this hack
448d396
to
4c00bab
Compare
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.
Great work @gregfurman 👏
Thank you for the comprehensive test coverage and unifying tag storage ✨
sidenote: the PR description mentions "Fixes issue#x", which auto-closes the issue. We typically ask the customer for feedback using the response-required tag and stale bot to foster feedback instead of directly closing upon merge. It also avoids notifying the customer too early before an ext image is shipped
Motivation
Changes
TestLambdaTag
suite to include tagging tests for Event Source Mappingstag_resource
,list_tags
, anduntag_resource
Lambda provider functions to use a provider-wde TaggingService. This allows for tagging of Lambda Event Source Mapping or Lambda Function resources (with support for CSC but this is not yet implemented).Testing