简体   繁体   中英

"internal server error" with API gateway and lambda on AWS

There are tons of similar questions both on this site and on the web, which leads me to believe there is something really wrong with AWS' documentation due to this causing grief to so many people.

So, I decided to post the most basic example step by step.

First, we create a new function:

在此处输入图像描述

It has default "everything", I don't touch a single line of code.

在此处输入图像描述

(the red error message is AWS not playing nice with Firefox)

The default code passes the test:

在此处输入图像描述

Now I add a trigger:

在此处输入图像描述

This gives me the link for the trigger:

在此处输入图像描述

I can go to the API endpoint: https://spy3z1jvu8.execute-api.ap-northeast-1.amazonaws.com/default/test

And it works:

在此处输入图像描述

Now, the problems will start. I open the API gateway that was created:

在此处输入图像描述

and try the default link: https://spy3z1jvu8.execute-api.ap-northeast-1.amazonaws.com

And...

在此处输入图像描述

Most of the people having similar questions seem to be having an issue with the gateway expecting some json content, etc, but here is an untouched AWS sample and the gateway link doesn't work.

The troubleshooting steps say to add logging and troubleshoot it that way, but there is nothing of interest in the logs.

What could be the origin of that problem?

What could be the origin of that problem?

You are correct. This is AWS/console fault. Specifically, it provides wrong permissions in the lambda's resource-based permissions for the default route to work. To fix that you have to edit the permissions .

Specifically, go to your function's Resource-based policy (this is different then execution role). You should find one Policy statement there which you have to edit. Then change in Source ARN from something like:

arn:aws:execute-api:ffffff:xxxx:api-id/*/*/function-name

to

arn:aws:execute-api:ffffff:xxxx:api-id/*/*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM