0
0
AWScloud~30 mins

Serverless Application Model (SAM) in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
Build a Simple Serverless API with AWS SAM
📖 Scenario: You are creating a simple serverless API to handle user requests without managing servers. AWS SAM helps you define and deploy this API easily.
🎯 Goal: Build an AWS SAM template that defines a Lambda function triggered by an API Gateway HTTP GET request.
📋 What You'll Learn
Create a SAM template with AWS::Serverless::Function resource
Define a Lambda function named UserFunction
Set the runtime to python3.12
Add an API Gateway event trigger for HTTP GET on path /users
Specify the handler as app.lambda_handler
💡 Why This Matters
🌍 Real World
Serverless applications let you run code without managing servers. AWS SAM simplifies building and deploying these applications.
💼 Career
Understanding AWS SAM is essential for cloud developers and architects working with serverless architectures on AWS.
Progress0 / 4 steps
1
Create the basic SAM template structure
Create a SAM template starting with AWSTemplateFormatVersion set to '2010-09-09' and Transform set to 'AWS::Serverless-2016-10-31'. Also add an empty Resources section.
AWS
Need a hint?

Start with the SAM template header and an empty Resources dictionary.

2
Add the Lambda function resource
Inside Resources, add a resource named UserFunction of type AWS::Serverless::Function. Set the Runtime to python3.12 and the Handler to app.lambda_handler.
AWS
Need a hint?

Define the Lambda function resource with the correct runtime and handler.

3
Add API Gateway event trigger
Under UserFunction properties, add an Events section. Define an event named UserApi with Type set to Api. Set the Properties of this event to have Path as /users and Method as get.
AWS
Need a hint?

Add the API Gateway event trigger under the Lambda function properties.

4
Add function memory size and timeout
Under UserFunction properties, add MemorySize set to 128 and Timeout set to 10 seconds to optimize the function configuration.
AWS
Need a hint?

Set memory size and timeout to control function resources and execution time.