Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Deploying a Serverless Application Using AWS Lambda, API Gateway, and DynamoDB

During this hands-on lab you will explore how to create and host an entirely serverless application leveraging some of the most popular AWS offerings. You will deploy the application using an architecture that uses Amazon API Gateway, AWS Lambda, and Amazon DynamoDB. Let's get building!

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Advanced
Duration
Clock icon 45m
Published
Clock icon Feb 15, 2024

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Create the DynamoDB Table

    Create a DynamoDB table with the following settings:

    • Table Name: Quotes
    • Partition Key Name: quote with type String
    • Sort Key Name: author with type String
    • Table settings: Customize settings
    • Table class: DynamoDB Standard
    • Read/write Capacity mode: Provisioned
    • Read Capacity Auto scaling: On
    • Minimum capacity units: 1, Maximum capacity units: 5, Target utilization (%) : 20
    • Write capacity Auto scaling: On
    • Minimum capacity units: 1, Maximum capacity units: 5, Target utilization (%) : 20
    • Encryption at rest: AWS managed key
  2. Challenge

    Create Lambda Functions

    Create two different Lambda functions to leverage with Amazon API Gateway.

    The code for each function is provided to you, so you do not need to type these manually.


    PutQuotes Function

    • Function Name: PutQuotes
    • Timeout: 1 Minute
    • Environment Variable Key: TABLE_NAME
    • Environment Variable Value: Quotes
    • New Execution Role Name: PutQuotesRole
    • Permissions Template: Simple microservice permissions (AWS sample)
    • Python Code

    GetQuotes Function

    • Function Name: GetQuotes
    • Timeout: 1 Minute
    • Environment Variable Key: TABLE_NAME
    • Environment Variable Value: Quotes
    • New Execution Role Name: GetQuotesRole
    • Permissions Template: Simple microservice permissions (AWS sample)
    • Python Code
  3. Challenge

    Create Regional REST API

    In Amazon API Gateway create a new API resource with the following information:

    • API Name: Quotes
    • API Type: Regional

    Now, create two new resources for use within the application. These resources should be created at the root (Example: /PutQuotes)

    Resource: PutQuotes

    • Resource Name: PutQuotes
    • Method Type: ANY
    • Integration Type: Lambda Function
    • Lambda Proxy Integration: Disabled
    • Lambda Function: PutQuotes

    Resource: GetQuotes

    • Resource Name: GetQuotes
    • Method Type: ANY
    • Integration Type: Lambda Function
    • Lambda Proxy Integration: Enabled
    • Lambda Function: GetQuotes
  4. Challenge

    Create Lambda Function Roles

    This should be created while you create the Lambda functions.

    1. PutQuoutes Role Name: PutQuotesRole
    2. GetQuotes Role Name: GetQuotesRole

    Each Role needs the ability to write to Amazon CloudWatch Logs, and it needs to be able to read and write to your Amazon DynamoDB Quotes table.

  5. Challenge

    Deploy, Log, and Test

    • Deploy the Quotes REST API to a new stage.
    • Under API Gateway Settings, set up a CloudWatch log role using the ARN from the IAM role that was created for you called OurApiGatewayToCloudWatchLogsRole
    • Under Logs and tracing settings of the Quotes REST API, set CloudWatch logs to Full requests and response logs and Enable X-Ray tracing.
    • Navigate to the invoke URL provided and append /PutQuotes to the end and hit Enter.
    • You will receive a message saying Item successfully written to DynamoDB if working correctly.
    • Refresh the page several times and verify that the function is working as intended by exploring the DynamoDB table items.
    • Replace the /PutQuotes resource with /GetQuotes in the Invoke URL.
    • You should receive a simple message with a quote! Refresh to randomly select quotes from the database.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans