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

[cherry release/3.4.x] backport aws lambda refactor change #11906

Merged
merged 6 commits into from
Nov 3, 2023

Conversation

windmgc
Copy link
Member

@windmgc windmgc commented Nov 2, 2023

Summary

This PR backports AWS-Lambda plugin refactor related changes to 3.4 release.

PR List:
#11350
#11413
#11551
#11614
#11800
#11805

Checklist

  • The Pull Request has tests
  • A changelog file has been created under changelog/unreleased/kong or skip-changelog label added on PR if changelog is unnecessary. README.md
  • There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Full changelog

  • [Implement ...]

Issue reference

Fix FTI-5528

windmgc and others added 4 commits November 2, 2023 16:20
…aws (#11350)

* refactor(aws-lambda): add lua-resty-aws library and libexpat dependencies into rockspec and bazel configs

The commit introduces latest version of lua-resty-aws as Kong's
dependency. Since lua-resty-aws relies on luaexpat to do xml decoding,
Kong also needs to build libexpat during compiling/packaging.

* refactor(aws-lambda): use lua-resty-aws and rewrite fetch credential

The commits rewrite part of the aws-lambda plugin code so that the IAM
role credential fetching is replaced by using lua-resty-aws credential
provider.

* refactor(aws-lambda): refactor aws-lambda plugin

This commits does refactoring on the majority of the aws-lambda plugin
code. The IAM role credential fetching and lambda function invoking has
been replaced by using the lua-resty-aws library directly.

* style(*): remove useless lua file

* fix(cd): fix explain manifest for libexpat

* fix(cd): fix buildifier style

* fix(*): try to fix lambda plugin init_worker

* fix(*): fix http proxy & sts regional endpoint config

* fix(*): execute plugin init code correctly

* fix(*): remove lambda returned content length

* chore(*): move libexpat from cross_deps to standalone repo

* fix(*): do not override global config credential

* chore(*): remove non-debug flag

* chore(*): bump lua-resty-aws version to 1.3.0
…ion mode (#11413)

* tests(aws-lambda): add response content type for multiple tests, add proxy integration test for sam

* fix(aws-lambda): better type & error handling when extracting proxy response

* tests(aws-lambda): fix test

* docs(changelog): add missing changelog
…ntial provider (#11551)

This PR contains a fix to let aws-lambda plugin-level proxy configuration take effect when fetching IAM credentials in an EKS environment. The EKS IRSA credential provider(aka TokenFileWebIdentityCredentials) will fire a request to AWS STS service when fetching the credential, and the request itself may need to go through the plugin-level proxy configuration. Here we check if a proxy is configured and whether the plugin is running inside the EKS environment with IRSA related configuration provided, then we replace the provider with a new TokenFileWebIdentityCredentials that supports proxy.

FTI-5242
### Summary

Lazily initializes AWS library on a first use, to remove startup delay caused
by AWS metadata discovery.

Signed-off-by: Aapo Talvensaari <[email protected]>
@windmgc windmgc force-pushed the ce-cherry-aws-lambda-refactor branch from 8d48e85 to b1bba5b Compare November 2, 2023 08:20
@windmgc windmgc marked this pull request as ready for review November 2, 2023 08:20
windmgc and others added 2 commits November 2, 2023 16:55
…11805)

Cache the aws lambda service by composing a cache key using the service related fields, so that service object can be reused between plugins and vault refresh can take effect when key/secret is rotated

* fix(aws-lambda): aws lambda service cache by service related fields

* tests(aws-lambda): add test for checking service cache refresh when vault rotates

* style(*): lint

Fix KAG-2832
Before the fix, error message is:
[kong] init.lua:405 [aws-lambda] table: 0x04183d70, client:127.0.0.1...

After:
[kong] init.lua:405 [aws-lambda] Function not found: arn:aws:lambda:us-east-1:xxx:function:test-lambda-2, client: 127.0.0.1...
@windmgc windmgc force-pushed the ce-cherry-aws-lambda-refactor branch from b1bba5b to 88bbea0 Compare November 2, 2023 08:56
@ms2008
Copy link
Contributor

ms2008 commented Nov 3, 2023

Please update the description with a link to the PR this backport from so it can be tracked better.

@windmgc
Copy link
Member Author

windmgc commented Nov 3, 2023

@ms2008 Sure! I've updated the PR description to contain a full list of backported PRs.

@windmgc windmgc merged commit 054e773 into release/3.4.x Nov 3, 2023
29 checks passed
@windmgc windmgc deleted the ce-cherry-aws-lambda-refactor branch November 3, 2023 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants