0
0
AWScloud~10 mins

Why serverless 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 handler in AWS Lambda.

AWS
def lambda_handler(event, context):
    return [1]
Drag options to blanks, or click blank then click option'
A"Hello from Lambda!"
Bprint("Hello")
Cevent + context
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of return
Returning None which gives no response
2fill in blank
medium

Complete the code to create an AWS Lambda function with a runtime environment.

AWS
resource "aws_lambda_function" "example" {
  function_name = "my_lambda"
  runtime       = [1]
  handler       = "index.lambda_handler"
  role          = aws_iam_role.lambda_role.arn
  filename      = "function.zip"
}
Drag options to blanks, or click blank then click option'
A"java8"
B"python2.7"
C"nodejs10.x"
D"python3.9"
Attempts:
3 left
💡 Hint
Common Mistakes
Using outdated runtimes
Choosing a runtime that doesn't match the code
3fill in blank
hard

Fix the error in the AWS SAM template to define a serverless function with correct memory size.

AWS
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: python3.9
      MemorySize: [1]
Drag options to blanks, or click blank then click option'
A512MB
B0.5GB
C512
D512MBs
Attempts:
3 left
💡 Hint
Common Mistakes
Adding units like MB or GB
Using decimal or string values
4fill in blank
hard

Fill both blanks to configure an API Gateway trigger for a Lambda function in Terraform.

AWS
resource "aws_lambda_permission" "apigw" {
  statement_id  = "AllowAPIGatewayInvoke"
  action        = [1]
  function_name = aws_lambda_function.my_lambda.function_name
  principal     = [2]
  source_arn    = aws_api_gateway_rest_api.myapi.execution_arn
}
Drag options to blanks, or click blank then click option'
A"lambda:InvokeFunction"
B"lambda:InvokeAsync"
C"apigateway.amazonaws.com"
D"events.amazonaws.com"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong action like InvokeAsync
Wrong principal service
5fill in blank
hard

Fill all three blanks to define a serverless function with environment variables and timeout in AWS SAM.

AWS
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: python3.9
      Timeout: [1]
      Environment:
        Variables:
          STAGE: [2]
          LOG_LEVEL: [3]
Drag options to blanks, or click blank then click option'
A30
B"prod"
C"INFO"
D300
Attempts:
3 left
💡 Hint
Common Mistakes
Setting timeout too high
Not quoting environment variable strings