Create an AWS Lambda function from scratch

Tomasz Łakomy
InstructorTomasz Łakomy
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 4 years ago

In this quick lesson we're going to learn how to create a brand new AWS Lambda function from scratch and show how to test the execution of a 'hello world' Lambda function

Tomasz Lakomy: [0:00] First login to your Amazon Web Services account. Afterwards, go to Services, and you can find Lambda under Compute, or you can also search for it over here, lambda.

[0:10] Before we can create a lambda function, we have to make sure that we are in the correct region. AWS Lambda is not a global service, so for instance, I'm based in Europe, so I'm going to create my functions in Europe, that is in Frankfurt.

[0:22] For instance, if you were based in US, you probably want to select one of those regions in order to declare your function in, because it's going to be probably closer to your users. Next, click on Create function.

[0:32] There are a number of options for us to choose, we can create our function from scratch, but we can also use a blueprint or deploy entire application from the AWS Serverless Application Repository. If you have a common use case, it's probably worth taking a look into some of those, because your problem may already be solved by the community, but we're going to create our function from scratch.

[0:51] I'm going to call my function, myFunction, and we're going to use Node.js 12.x. As you can see, there are also a number of other languages we could use.

[1:00] I'm going to click on Create function. Now, we have created our first lambda function.

[1:04] If we scroll down, we're going to see the sample code provided by the AWS. Whenever this function is going to be executed, we're going to return a following response, "statusCode of 200," which means, "HTTP OK," and the body is basically, going to be the string, "Hello from Lambda!" In order to test if this function works, click on Test.

[1:23] Here we can create a test event. Currently, we don't care about what is going to be provided to this function, so we're going to leave everything as default. I'm going to create my event name as "test." Create it.

[1:35] Afterwards, after I click Test, now I can see that my function has executed successfully. After I click on Details, I'm going to see the response, which we specified earlier. So, "statusCode of 200" and body, "Hello from Lambda!"

egghead
egghead
~ a minute ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today