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

ResourceGroupTagging: Fix filtering for lambda functions with "lambda:function" #7690

Merged
merged 2 commits into from
May 14, 2024

Conversation

kirberich
Copy link
Contributor

The resource group tagging api get_resources method doesn't allow for filtering for lambda functions using a lambda:function resource type filter, it's only checking for lambda - this adds support for that, in the same way it's done for other kinds of resources

First commit has the failing test:

        resp = rtapi.get_resources(ResourceTypeFilters=["lambda:function"])
>       assert_response(resp, [circle_arn, rectangle_arn])

tests/test_resourcegroupstaggingapi/test_resourcegroupstaggingapi.py:708: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

response = {'ResourceTagMappingList': [], 'ResponseMetadata': {'HTTPHeaders': {'date': 'Mon, 13 May 2024 11:09:28 GMT', 'server':...Hw8'}, 'HTTPStatusCode': 200, 'RequestId': 'YRtMzouuFVfnMx5K4jhUXR0Of8m1k7vdSQHKA1JcQSdRgKLvQHw8', 'RetryAttempts': 0}}
expected_arns = ['arn:aws:lambda:us-west-2:123456789012:function:lambda-tag-value-1', 'arn:aws:lambda:us-west-2:123456789012:function:lambda-tag-value-2']

    def assert_response(response, expected_arns):
        results = response.get("ResourceTagMappingList", [])
        resultArns = []
        for item in results:
            resultArns.append(item["ResourceARN"])
        for arn in resultArns:
            assert arn in expected_arns
        for arn in expected_arns:
>           assert arn in resultArns
E           AssertionError: assert 'arn:aws:lambda:us-west-2:123456789012:function:lambda-tag-value-1' in []

Copy link

codecov bot commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.32%. Comparing base (de19a6c) to head (ce25d38).
Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7690   +/-   ##
=======================================
  Coverage   94.32%   94.32%           
=======================================
  Files        1087     1087           
  Lines       92692    92692           
=======================================
+ Hits        87434    87435    +1     
+ Misses       5258     5257    -1     
Flag Coverage Δ
servertests 29.41% <100.00%> (ø)
unittests 94.29% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thank you for fixing this @kirberich!

@bblommers bblommers changed the title Fix filtering for tagged lambda functions with "lambda:function" ResourceGroupTagging: Fix filtering for lambda functions with "lambda:function" May 14, 2024
@bblommers bblommers added this to the 5.0.8 milestone May 14, 2024
@bblommers bblommers merged commit 792f7a3 into getmoto:master May 14, 2024
39 checks passed
Copy link
Contributor

This is now part of moto >= 5.0.8.dev6

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.

None yet

2 participants