Internal server error but no logs?
Wiring up a Lambda function to API Gateway takes a few steps. If you miss one the route to your function won’t be complete and API Gateway will drop your request (or message if you’re using WebSockets).
Make sure you do all of these steps:
- Create a Lambda function (in CDK’s Lambda module this is
new Function(...
) which requires: id
an identifier for the functionFunctionProps
the properties used to build the function- Create an integration (in CDK’s API Gateway v2 module this is
new CfnIntegration(...
) which requires: apiId
- in CDK it isapi.ref
if thenew CfnApi(...
call’s result was stored in a variable calledapi
integrationType
- usuallyAWS_PROXY
integrationUri
- an API Gateway ARN that contains the ARN of the Lambda function it is using like thisarn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:512341234123:function:myfunction-EB2081F1-4R5RskdFGSYU/invocations
credentialsArn
- the ARN of a role that can be assumed by the service principalapigateway.amazonaws.com
- Create a route (in CDK’s API Gateway v2 module this is
new CfnRoute(...
step) which requires: apiId
- same as aboverouteKey
- which is the path that API Gateway should use to filter requests/messages for this integrationauthorizationType
-NONE
for no authorization, but there are many other optionstarget
- in TypeScript CDK it isintegrations/${integration.ref}
if thenew CfnIntegration(...
call from above was stored in a variable calledintegration
If that doesn’t work make sure you have API Gateway logging turned on and see if your requests are getting routed to another integration.