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

fix(aws-lambda): let plugin level proxy take effect on EKS IRSA credential provider #11551

Merged
merged 3 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG/unreleased/kong/11551-1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"message": "**AWS-Lambda**: let plugin-level proxy take effect on EKS IRSA credential provider"
"type": "bugfix"
"scope": "Plugin"
"prs":
- 11551
"jiras":
- "FTI-5242"
6 changes: 6 additions & 0 deletions CHANGELOG/unreleased/kong/11551-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
message: "Bumped lua-resty-aws from 1.3.1 to 1.3.2"
type: dependency
prs:
- 11551
jiras:
- "FTI-5242"
2 changes: 1 addition & 1 deletion kong-3.5.0-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies = {
"lua-protobuf == 0.5.0",
"lua-resty-healthcheck == 1.6.3",
"lua-messagepack == 0.5.2",
"lua-resty-aws == 1.3.1",
"lua-resty-aws == 1.3.2",
"lua-resty-openssl == 0.8.25",
"lua-resty-counter == 0.2.1",
"lua-resty-ipmatcher == 0.6.1",
Expand Down
21 changes: 21 additions & 0 deletions kong/plugins/aws-lambda/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,33 @@ function AWSLambdaHandler:access(conf)
if not lambda_service then
local credentials = AWS.config.credentials
-- Override credential config according to plugin config
-- Note that we will not override the credential in AWS
-- singleton directly because it may be needed for other
-- scenario
if conf.aws_key then
local creds = AWS:Credentials {
accessKeyId = conf.aws_key,
secretAccessKey = conf.aws_secret,
}

credentials = creds

elseif conf.proxy_url
-- If plugin config has proxy, then EKS IRSA might
-- need it as well, so we need to re-init the AWS
-- IRSA credential provider
and AWS_GLOBAL_CONFIG.AWS_WEB_IDENTITY_TOKEN_FILE
and AWS_GLOBAL_CONFIG.AWS_ROLE_ARN then
local creds = AWS:TokenFileWebIdentityCredentials()
creds.sts = AWS:STS({
region = region,
stsRegionalEndpoints = AWS_GLOBAL_CONFIG.sts_regional_endpoints,
ssl_verify = false,
http_proxy = conf.proxy_url,
https_proxy = conf.proxy_url,
})

credentials = creds
end

-- Assume role based on configuration
Expand All @@ -74,6 +94,7 @@ function AWSLambdaHandler:access(conf)
credentials = credentials,
region = region,
stsRegionalEndpoints = AWS_GLOBAL_CONFIG.sts_regional_endpoints,
ssl_verify = false,
http_proxy = conf.proxy_url,
https_proxy = conf.proxy_url,
})
Expand Down