How To Return HTML From AWS Lambda (1 Min)

preview_player
Показать описание
In this video, you'll learn how to return HTML content from an AWS Lambda function.



Video Transcript:
_
Hi guys, this is Abhi from Gokcedb. In this video, you are going to learn how to return HTML content from AWS Lambda Function. Let’s start by searching for Lambda on the AWS Console, then click on the function in the left menu followed by create function.

Give your function a name and run time. I’m going to select Phyton and leave everything else to default. Hit create function then navigate to the Code Source section.

Here I am going to paste HTML code for a form in an HTML Variable. I am also going to plug in the HTML Variable in my return body. Hit deploy, then click on the Test button.

Give your Test Event a name then hit save and then click on test again. Looks like our Lambda Function is working as expected. Now click on the Configuration tab then select the function URL from the left menu.

Hit the Create Function URL button and the Auth type. I am going to select none and then hit save. If you click on the Function URL, you’ll see that your HTML code is being returned text.

To fix this, go back to the Code Source section, and add headers to the return data structure with the content type of text, slash HTML. Hit deploy and go back to the function URL.

Refresh the webpage and now you should see the HTML form being redone. There you have it. Make sure you like, subscribe, and turn on the notification bell. Until next time.
Рекомендации по теме
Комментарии
Автор

The fact that you start talking about the main topic in like 3 secs just makes me like your videos

tsace
Автор

Helo, how to get that input from the form when clicked submit button? so that i can used that input data in further code in a python file.

SuryaRegalla
Автор

Hi Abi, great tutorial! I used AWS cdk to deploy my lambda with docker and also created the function url through the cdk itself upon initial deployment. My lambda is running successfully and the function url settings are the same as yours however when I try to click on my function url, I get “internal server error”. Have you run in to this issue before?

inFAMOUSboy
Автор

very good and very objective. congrats and thanks!

renatcam
Автор

Hello, please do a part 2. How can we receive the data from the HTML form into lambda? And possibly save it to dynamodb.

junivensaavedra