AWS SAM is a framework that helps you build and deploy serverless applications easily using simple templates.
Click to reveal answer
beginner
Which file format does SAM use to define serverless applications?
SAM uses a YAML or JSON template file to define resources like functions, APIs, and databases.
Click to reveal answer
intermediate
How does SAM simplify deploying AWS Lambda functions?
SAM lets you define Lambda functions and their triggers in one template, then deploys them with a single command.
Click to reveal answer
intermediate
What command do you use to locally test a SAM application?
You use 'sam local invoke' to run Lambda functions locally and 'sam local start-api' to test APIs on your machine.
Click to reveal answer
advanced
Why is SAM considered a best practice for serverless development?
SAM provides a clear structure, easy deployment, local testing, and integrates well with AWS services, making serverless development faster and safer.
Click to reveal answer
What does AWS SAM primarily help you manage?
AServerless applications
BVirtual machines
CDatabase schemas
DNetwork firewalls
✗ Incorrect
AWS SAM is designed to manage serverless applications like Lambda functions and APIs.
Which file extension is commonly used for SAM templates?
A.yaml
B.exe
C.html
D.docx
✗ Incorrect
SAM templates are usually written in YAML format with the .yaml extension.
Which command lets you deploy a SAM application to AWS?
Asam local invoke
Bsam build
Csam delete
Dsam deploy
✗ Incorrect
'sam deploy' uploads your application to AWS and creates the resources.
What is the purpose of 'sam local start-api'?
ATo build Lambda functions
BTo test API Gateway locally
CTo delete APIs
DTo deploy APIs to AWS
✗ Incorrect
'sam local start-api' runs your API Gateway locally for testing.
Which AWS service does SAM mainly work with?
AAmazon EC2
BAmazon RDS
CAWS Lambda
DAWS S3
✗ Incorrect
SAM is focused on managing AWS Lambda functions and related serverless resources.
Explain what AWS Serverless Application Model (SAM) is and how it helps developers.
Think about how SAM makes serverless apps easier to create and manage.
You got /4 concepts.
Describe the process of testing and deploying a serverless application using SAM.
Consider how you test locally before sending your app to AWS.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of AWS Serverless Application Model (SAM)?
easy
A. To simplify building and deploying serverless applications using a single template
B. To manage virtual machines in the cloud
C. To create relational databases automatically
D. To monitor network traffic in AWS
Solution
Step 1: Understand SAM's role
SAM is designed to help developers define serverless functions and their triggers in one file.
Step 2: Compare options
Options A, B, and C describe unrelated AWS services or functions, while D correctly describes SAM's purpose.
Final Answer:
To simplify building and deploying serverless applications using a single template -> Option A
Quick Check:
SAM purpose = Simplify serverless apps [OK]
Hint: SAM = single template for serverless apps [OK]
Common Mistakes:
Confusing SAM with EC2 or database services
Thinking SAM manages infrastructure like VMs
Assuming SAM is for monitoring
2. Which of the following is the correct syntax to define a Lambda function in a SAM template?
easy
A. MyFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: python3.8
B. MyFunction:
Type: AWS::Lambda::Function
Properties:
Handler: index.handler
Runtime: python3.8
C. MyFunction:
Type: AWS::EC2::Instance
Properties:
Handler: index.handler
Runtime: python3.8
D. MyFunction:
Type: AWS::S3::Bucket
Properties:
Handler: index.handler
Runtime: python3.8
Solution
Step 1: Identify SAM Lambda function resource type
SAM uses the resource type AWS::Serverless::Function to define Lambda functions.
Step 2: Check other options
MyFunction:
Type: AWS::Lambda::Function
Properties:
Handler: index.handler
Runtime: python3.8 uses AWS::Lambda::Function which is CloudFormation but not SAM shorthand. Options C and D are unrelated resource types.
Final Answer:
MyFunction with Type AWS::Serverless::Function and correct properties -> Option A
Quick Check:
SAM Lambda function type = AWS::Serverless::Function [OK]
Hint: SAM Lambda uses AWS::Serverless::Function type [OK]
Common Mistakes:
Using AWS::Lambda::Function instead of AWS::Serverless::Function
Confusing resource types like EC2 or S3 for Lambda
Missing required properties like Handler or Runtime
3. Given this SAM template snippet, what event triggers the Lambda function?
MyFunction:
Type: AWS::Serverless::Function
Properties:
Handler: app.lambda_handler
Runtime: python3.8
Events:
ApiEvent:
Type: Api
Properties:
Path: /hello
Method: get
medium
A. A scheduled timer triggers the Lambda
B. An S3 file upload triggers the Lambda
C. A DynamoDB table update triggers the Lambda
D. An HTTP GET request to /hello triggers the Lambda
Solution
Step 1: Identify event type in template
The event type is Api with Path /hello and Method get, meaning an HTTP GET request triggers the function.
Step 2: Eliminate other event types
S3 upload, scheduled timer, and DynamoDB update are different event types not shown here.
Final Answer:
An HTTP GET request to /hello triggers the Lambda -> Option D
Quick Check:
Api event with GET /hello = HTTP trigger [OK]
Hint: Api event with Method get means HTTP GET trigger [OK]
Common Mistakes:
Confusing Api event with S3 or timer events
Ignoring the Method and Path properties
Assuming default triggers without checking Events
4. You wrote this SAM template but deployment fails. What is the error?
C. The Events property under S3Event should be a list, not a string
D. The Bucket name cannot be hardcoded
Solution
Step 1: Check S3 event syntax
The Events property for S3 event must be a list of event types, but here it is a string.
Step 2: Verify other properties
Handler is present, python3.8 is supported, and bucket names can be hardcoded in SAM templates.
Final Answer:
The Events property under S3Event should be a list, not a string -> Option C
Quick Check:
S3 Events property = list, not string [OK]
Hint: S3 Events must be a list, not a single string [OK]
Common Mistakes:
Using string instead of list for S3 Events
Removing required Handler property
Assuming runtime version is invalid without checking
5. You want to deploy a serverless app with two Lambda functions triggered by different events: one by HTTP GET /users and another by S3 file upload to bucket 'data-bucket'. Which SAM template snippet correctly defines both functions?