3

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:

enter image description here

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

enter image description here

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

The default code passes the test:

enter image description here

Now I add a trigger:

enter image description here

This gives me the link for the trigger:

enter image description here

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

And it works:

enter image description here

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

enter image description here

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

And...

enter image description here

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?

0

1 Answer 1

5

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/*/*
Sign up to request clarification or add additional context in comments.

4 Comments

that works, thanks! There is no way I'd have found it like that. Do you know what is the reason they are setting it like this?
@Thomas Glad it worked out. It could be security. The default permissions are less permissive then the modified version.
didn't quite worked for me
@IceBear You should make new question specific to your issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.