You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But this is not strictly true, when AWS lambda is run locally through the AWS SAM start-lambda command, a thin HTTP layer (not an AWS Gateway API layer) is stood up in front of the lambdas so they can be hit locally. As far as I can tell, there is no way through AWS SAM parameters to start this endpoint up over HTTPS, it always uses HTTP locally.
In order to get around this, we've configured our lambda routes in our declarative kong.yml config to point back to Kong itself to perform SSL termination. This config is specifically for Kong 2.8.1 but I also tried Kong 3.0.0 with minor updates to handle the AWS host/region change and saw similar results.
Note the port used is 8443 which is Kong itself. Then, we have Kong catch the request using an AWS lambda header and perform the actual request to our local AWS Lambda HTTP endpoint running on port 3001:
Not to conflate this issue, but I'm also dealing with a problem I haven't been able to solve yet that may be related to the way we're implementing this work-around. Somehow, Kong is not generating the X-Forwarded* headers when it proxies these requests. Our Lambda function depends on X-Forwarded-Proto and fails requests (though I can see that none of the X-Forwarded* headers are generated by Kong, not just X-Forwarded-Proto). I'm hoping that by allowing the plugin to natively use HTTP and removing our work-around will address that issue. We've confirmed that X-Forwarded* headers are properly generated when Kong is deployed in AWS. This header is not related to trusted IPs. Our work-around for this problem is to put the X-Forwarded-Proto header on our initial requests in development and Kong does correctly forward the header, it just doesn't generate it itself or the generated header is getting dropped somewhere inside Kong.
Expected Behavior
Kong should be able to talk directly to a Lambda running locally through sam local start-lambda without requiring work-arounds to handle the hard-coded HTTPS URI that Kong constructs.
Steps To Reproduce
Spin up Kong on a docker network
Define a Lambda + SAM template definition with AWS SAM's template.yaml to facilitate local development
Start a Lambda HTTP endpoint locally using:
sam local start-lambda --docker-network <YOUR DOCKER NETWORK RUNNING KONG>
Configure Kong with a route/service to point to your Lambda
Kong will exclusively generate SSL URIs for contacting the Lambda and the request will fail.
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Kong version (
$ kong version
)2.8.1, 3.0.0
Current Behavior
Kong hard-codes the URL generation for the endpoint to use when contacting AWS Lambda functions in the Kong AWS Lambda Plugin.
https://github.com/Kong/kong/blob/master/kong/plugins/aws-lambda/handler.lua#L294
In a recent, related PR, it was said:
But this is not strictly true, when AWS lambda is run locally through the AWS SAM start-lambda command, a thin HTTP layer (not an AWS Gateway API layer) is stood up in front of the lambdas so they can be hit locally. As far as I can tell, there is no way through AWS SAM parameters to start this endpoint up over HTTPS, it always uses HTTP locally.
In order to get around this, we've configured our lambda routes in our declarative kong.yml config to point back to Kong itself to perform SSL termination. This config is specifically for Kong 2.8.1 but I also tried Kong 3.0.0 with minor updates to handle the AWS host/region change and saw similar results.
Note the port used is 8443 which is Kong itself. Then, we have Kong catch the request using an AWS lambda header and perform the actual request to our local AWS Lambda HTTP endpoint running on port 3001:
Not to conflate this issue, but I'm also dealing with a problem I haven't been able to solve yet that may be related to the way we're implementing this work-around. Somehow, Kong is not generating the X-Forwarded* headers when it proxies these requests. Our Lambda function depends on X-Forwarded-Proto and fails requests (though I can see that none of the X-Forwarded* headers are generated by Kong, not just X-Forwarded-Proto). I'm hoping that by allowing the plugin to natively use HTTP and removing our work-around will address that issue. We've confirmed that X-Forwarded* headers are properly generated when Kong is deployed in AWS. This header is not related to trusted IPs. Our work-around for this problem is to put the X-Forwarded-Proto header on our initial requests in development and Kong does correctly forward the header, it just doesn't generate it itself or the generated header is getting dropped somewhere inside Kong.
Expected Behavior
Kong should be able to talk directly to a Lambda running locally through
sam local start-lambda
without requiring work-arounds to handle the hard-coded HTTPS URI that Kong constructs.Steps To Reproduce
The text was updated successfully, but these errors were encountered: