1. 9
    Attach an API Gateway to a lambda function deployed with AWS CDK
    3m 29s

Attach an API Gateway to a lambda function deployed with AWS CDK

InstructorTomasz Łakomy

Share this video with your friends

Send Tweet

Serverless technologies like AWS Lambda allow us to build our applications out of small, independent functions that can be called based on events such as an API call.

By default, it's not possible to call a lambda function from the Internet - it's safely stored within AWS cloud, following the principle of least privilege.

In order to create a REST API to call a lambda function we need to use API Gateway. Luckily, with AWS CDK, we can create a LambdaRestApi in 3 lines of code and this is exactly what we're going to learn in this quick lesson!

Matt
Matt
~ 6 months ago

In order to see the body returned by your lambda function in the browser, the Content-Type needs to be changed from plain/text to application.json

Leaving it as plain/text will just download a file to your computer instead of displaying the message in the browser. I believe this step was skipped in this lesson.

Matt
Matt
~ 6 months ago

Also, if you do not see the api endpoints listed when scrolling down, you need to click on the "API Gateway" box within the designer.

Todor
Todor
~ 6 months ago

Running "cdk diff" with the packages at version 1.55.0 works fine. However the newest (08.08.2020) version 1.57.0 would throw an error:

$ cdk diff

unable to determine cloud assembly output directory. Assets must be defined indirectly within a "Stage" or an "App" scope"

Tomasz Łakomy
Tomasz Łakomy(instructor)
~ 6 months ago

Thanks for the notice, I’ll take a look as soon as I can :)

Tunca Tunc
Tunca Tunc
~ 4 months ago

Tomasz, thanks for the great course. I have to do yarn build, after that cdk diff shows diff.