0
0
AWScloud~10 mins

Why serverless architecture matters in AWS - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a serverless function using AWS Lambda.

AWS
def handler(event, context):
    return [1]
Drag options to blanks, or click blank then click option'
Aprint("Hello")
Bevent
Ccontext
D"Hello from Lambda!"
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of return
Returning the event or context object directly
2fill in blank
medium

Complete the code to create an AWS Lambda function trigger from an API Gateway event.

AWS
def handler(event, context):
    if event["httpMethod"] == [1]:
        return {"statusCode": 200, "body": "Success"}
Drag options to blanks, or click blank then click option'
A"GET"
B"POST"
C"PUT"
D"DELETE"
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST or PUT instead of GET
Missing quotes around the method string
3fill in blank
hard

Fix the error in the AWS SAM template to define a Lambda function resource.

AWS
Resources:
  MyFunction:
    Type: [1]
    Properties:
      Handler: index.handler
      Runtime: python3.9
      CodeUri: ./src/
Drag options to blanks, or click blank then click option'
A"AWS::Serverless::Function"
B"AWS::S3::Bucket"
C"AWS::Lambda::Function"
D"AWS::EC2::Instance"
Attempts:
3 left
💡 Hint
Common Mistakes
Using AWS::Lambda::Function instead of AWS::Serverless::Function
Using unrelated resource types
4fill in blank
hard

Fill both blanks to configure an AWS Lambda function with environment variables and memory size.

AWS
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      MemorySize: [1]
      Environment:
        Variables:
          STAGE: [2]
Drag options to blanks, or click blank then click option'
A512
B"prod"
C"dev"
D128
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings for MemorySize
Using numbers without quotes for environment variables
5fill in blank
hard

Fill all three blanks to create a serverless function with an S3 trigger and proper permissions.

AWS
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: python3.9
      Events:
        S3Event:
          Type: S3
          Properties:
            Bucket: [1]
            Events: [2]
      Policies:
        - [3]
Drag options to blanks, or click blank then click option'
A"my-upload-bucket"
B"s3:ObjectCreated:*"
C"AmazonS3ReadOnlyAccess"
D"arn:aws:s3:::my-upload-bucket"
Attempts:
3 left
💡 Hint
Common Mistakes
Using ARN instead of bucket name for Bucket
Incorrect event string
Wrong policy name