Create Function - Lambda

AWS Lambda will run your code in response to events such as an HTTP requests.

In this step, you will build the core function that will process API requests from the web application to dispatch a unicorn.


  • In the next module, you will use AWS API Gateway to create a RESTFul API that will expose an HTTP endpoint that can be invoked from your user’s browsers.
  • You will then connect the Lambda function you create in this step to that API in order to create a fully functional backend for your web application.

Steps summary:

  1. You will use the AWS Lambda console to create a new Lambda function called RequestUnicorn that will process the API requests
  2. Use the provided example implementation for your function code
  3. Just copy and paste from that file into the AWS Lambda console’s editor
  4. Do not forget to configure your function to use the WildRydesLambda IAM role you created in the previous section

Step-by-steps directions:

Step 1: Go to the AWS Lambda console

Step 2: Click Create Function backend

Step 3: Keep the default Author from scratch card selected

Step 4: Enter RequestUnicorn in the Name field

Step 5: Select Python 3.8 for the Runtime backend

Step 6: Expand Choose or create an execution role under Permissions

Step 7: Ensure Choose an existing role is selected from the Role dropdown backend

Step 8: Select WildRydesLambda from the Existing Role dropdown backend

Step 9: Click on Create Function

Step 10: Scroll down to the Function Code section and replace the existing code in the code editor with the contents of


Step 11: Click Save in the upper right corner of the page