Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Lambda permissions #7336

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

Merged
merged 25 commits into from
Dec 28, 2022
Merged

Lambda permissions #7336

merged 25 commits into from
Dec 28, 2022

Conversation

joe4dev
Copy link
Member

@joe4dev joe4dev commented Dec 15, 2022

Tests and fixes several TODOs related to Lambda permissions and ARN, qualifier handling, especially focusing on API validation and exception handling.
All changes apply to the new lambda provider enabled through PROVIDER_OVERRIDE_LAMBDA=asf

  • Validation + exception testing for add_permission
  • Fix add_permission exception handling
  • Fix alias detection regex (see new unit tests, manually validated against AWS, some cases are covered in parity tests).
  • Check the scope of uniqueness constraint (see TODO: is this unique just in the policy or across all policies in region/account/function (?) in provider.py)
  • Fix disparity behavior when publishing a new version. Observation: Publishing a new lambda version creates a new revision id for the permission associated with $LATEST. The current implementation doesn’t reflect that
  • Fix disparity when adding permissions to old versions. Probably a follow-up issue due to the publishing version disparity
  • revision_id for remove_permission
  • revision_id for add_permission
  • Double-check against old impl: localstack.services.awslambda.lambda_api.add_permission_policy_statement
  • Generalize function name (ARN, ARN shortname) and qualifier resolving and re-use for lambda permissions
  • Check where new helpers _validate_qualifier_expression and _resolve_fn_qualifier could be re-used in lambda (e.g., see TODOs in create_function_url_config)
  • Extend localstack.services.awslambda.api_utils.build_statement (hard to test
  • test Alexa (see TODO: add test for event_source_token (alexa smart home) and auth_type)

Follow-Up (out of scope in this PR)

  • Test + implement revisions for lambda in general (with versions, aliases, layers, etc). It seems that the revision id of permissions is the same as for qualified lambdas (i.e., VersionFunctionConfiguration).
  • MAYBE write a failing test for actual permission behavior (manually validated with SNS, tried SQS, but synchronous invocation via apigateway would be better because it executes much faster and more reliably)

@joe4dev joe4dev self-assigned this Dec 15, 2022
@joe4dev joe4dev temporarily deployed to localstack-ext-tests December 15, 2022 08:56 — with GitHub Actions Inactive
@joe4dev joe4dev marked this pull request as draft December 15, 2022 08:56
@github-actions
Copy link

github-actions bot commented Dec 15, 2022

LocalStack integration with Pro

       3 files  ±0         3 suites  ±0   1h 27m 42s ⏱️ + 4m 28s
1 579 tests +2  1 303 ✔️ ±0  276 💤 +2  0 ±0 
2 229 runs  +6  1 671 ✔️ ±0  558 💤 +6  0 ±0 

Results for commit 5e25411. ± Comparison against base commit 1b40546.

♻️ This comment has been updated with latest results.

@joe4dev joe4dev temporarily deployed to localstack-ext-tests December 19, 2022 08:35 — with GitHub Actions Inactive
@coveralls
Copy link

coveralls commented Dec 19, 2022

Coverage Status

Coverage: 84.789% (+0.04%) from 84.749% when pulling d74ef93 on lambda-permissions into 1b40546 on master.

@joe4dev joe4dev temporarily deployed to localstack-ext-tests December 21, 2022 13:11 — with GitHub Actions Inactive
@joe4dev joe4dev temporarily deployed to localstack-ext-tests December 21, 2022 15:49 — with GitHub Actions Inactive
@joe4dev joe4dev temporarily deployed to localstack-ext-tests December 21, 2022 19:46 — with GitHub Actions Inactive
@joe4dev joe4dev temporarily deployed to localstack-ext-tests December 23, 2022 08:40 — with GitHub Actions Inactive
Copy link
Member

@dominikschubert dominikschubert left a comment

Choose a reason for hiding this comment

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

Looks awesome 👍

just some smaller questions so far

To be fixed in follow-up PR and tested for lambda in general.
Add snapshot tests for version and alias to capture sid scope.
@joe4dev joe4dev temporarily deployed to localstack-ext-tests December 23, 2022 13:10 — with GitHub Actions Inactive
@joe4dev joe4dev marked this pull request as ready for review December 23, 2022 13:12
@joe4dev joe4dev temporarily deployed to localstack-ext-tests December 23, 2022 14:40 — with GitHub Actions Inactive
@joe4dev joe4dev temporarily deployed to localstack-ext-tests December 23, 2022 15:16 — with GitHub Actions Inactive
Copy link
Member

@dominikschubert dominikschubert left a comment

Choose a reason for hiding this comment

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

Minor nit, otherwise LGTM though! 🥳
Feel free to merge after addressing it!

Good attention to detail and well documented 👍

Looking forward to the follow-up 😁

@joe4dev joe4dev temporarily deployed to localstack-ext-tests December 28, 2022 12:48 — with GitHub Actions Inactive
@joe4dev
Copy link
Member Author

joe4dev commented Dec 28, 2022

great, thanks for the suggestions @dominikschubert

@joe4dev joe4dev merged commit fe9811f into master Dec 28, 2022
@joe4dev joe4dev deleted the lambda-permissions branch December 28, 2022 12:53
@joe4dev joe4dev mentioned this pull request Jan 13, 2023
1 task
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.

3 participants