-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Lambda: improve function name and qualifier validation #11366
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 13m 55s ⏱️ - 21m 54s Results for commit b6f8a0e. ± Comparison against base commit 0063912. This pull request removes 916 and adds 72 tests. Note that renamed tests count towards both.
This pull request removes 97 skipped tests and adds 4 skipped 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.
Great first iteration! I found some issues with the validation, which would be nice to address before merging :)
2979749
to
4b4362b
Compare
4b4362b
to
b6f8a0e
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.
LGTM now! Thanks for adding those changes!
FYI: We squash commits anyway on merging, so it is not necessary to force push for changes, and keep the commit count low. Personally, I find it is easier, especially for review, if you can see the changes done after a review in separate commits. Others might disagree with this, though 😅
Motivation
Current validation checks for Lambda function names did not account for some invalid regex combinations as well as length limits for
FunctionName
differing between request types. This will add tests ensuring a wider range of invalidFunctionName
andQualfier
combinations are caught.Changes
The Lambda Provider:
create_function
in favour ofapi_utils.get_name_and_qualifier
DeleteFunction
The API utils
api_utils.py
:get_name_and_qualifier
-- which is ubiquitously used across the Lambda provider and should enact these checks.validate_function_name
(accounting specifically forCreateFunction
,DeleteFunction
,Invoke
, andGetFunction
) with sensible defaults being used elsewhere.validate_qualifier
andconstruct_validation_exception_message
The Lambda API tests:
test_function_name_and_qualifier_validation
which accounts for a wide range of possible exception cases when attempting validation.Testing
The below is a test table showing all scenarios tested for
CreateFunction
,DeleteFunction
GetFunction
andInvoke
test types.Some considerations:
create_function
request.create_function
request -- withResourceNotFoundException
being thrown for othe types. None are skipped to ensure parity with AWS.my-function!
my-function
invalid!
invalid-account:function:my-function
arn:aws:lambda:invalid-region:{account_id}:function:my-function
arn:aws:ec2:{region_name}:{account_id}:instance:i-1234567890abcdef0
"a" * max_length
arn:aws:lambda:invalid-region:{account_id}:function:my-function["a" * max_length]
arn:aws:lambda:invalid-region:{account_id}:function:my-function-["a" * max_length]
"a" * max_length
my-function
"a" * max_length
arn:aws:lambda:{region_name}:{account_id}:function:my-function:1:2
my-function
-1
create_function
arn:aws:lambda:{region_name}:{account_id}:function
create_function
function:my-function:$LATEST:extra
arn:aws:lambda:{region_name}:{account_id}:function:my-function:$LATEST
1
arn:aws:lambda:{region_name}:{account_id}:function:my-function
$latest
arn:aws:lambda::{account_id}:function:my-function
arn:aws:lambda:{region_name}::function:my-function
arn:aws:lambda:{region_name}:{account_id}:function:my-function:$LATES
Additional Pipelines
LocalStack Pro: IAM Policies Enforced
ext
: Partial run against tests inaws/tests/lambda_
and withENFORCE_IAM
enabled at GitHub workflowENV: ENFORCE_IAM=1
LocalStack Community: Multi-Account and Multi-Region
multi
: Multi-region/account build at CircleCI pipeline.TODO
What's left to do:
Potential future works
CreateFunction
,DeleteFunction
,GetFunction
, andInvoke