0
0
AWScloud~10 mins

Serverless vs container decision in AWS - Interactive Practice

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
resource "aws_lambda_function" "example" {
  function_name = "my_lambda_function"
  runtime       = "python3.9"
  handler       = "handler.[1]"
  role          = aws_iam_role.lambda_exec.arn
  filename      = "lambda_function.zip"
}
Drag options to blanks, or click blank then click option'
Amain
Blambda_handler
Capp
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using a handler name that does not exist in the code.
Confusing the handler with the filename.
2fill in blank
medium

Complete the code to define a container task in AWS ECS.

AWS
resource "aws_ecs_task_definition" "example" {
  family                   = "my_task"
  network_mode             = "awsvpc"
  requires_compatibilities = ["FARGATE"]
  cpu                      = "256"
  memory                   = "512"
  container_definitions    = jsonencode([
    {
      name      = "my_container",
      image     = "nginx:latest",
      essential = true,
      portMappings = [
        {
          containerPort = [1],
          hostPort      = 80,
          protocol      = "tcp"
        }
      ]
    }
  ])
}
Drag options to blanks, or click blank then click option'
A80
B22
C8080
D443
Attempts:
3 left
💡 Hint
Common Mistakes
Setting containerPort to a port not used by the container.
Confusing hostPort and containerPort.
3fill in blank
hard

Fix the error in the serverless function timeout setting.

AWS
resource "aws_lambda_function" "example" {
  function_name = "my_lambda_function"
  runtime       = "python3.9"
  handler       = "handler.lambda_handler"
  role          = aws_iam_role.lambda_exec.arn
  filename      = "lambda_function.zip"
  timeout       = [1]
}
Drag options to blanks, or click blank then click option'
A1000
B0
C900
D15
Attempts:
3 left
💡 Hint
Common Mistakes
Setting timeout to zero disables the function.
Using a timeout value greater than 900 seconds.
4fill in blank
hard

Fill both blanks to configure an ECS service with desired count and launch type.

AWS
resource "aws_ecs_service" "example" {
  name            = "my_service"
  cluster         = aws_ecs_cluster.example.id
  task_definition = aws_ecs_task_definition.example.arn
  desired_count   = [1]
  launch_type     = "[2]"
}
Drag options to blanks, or click blank then click option'
A2
B1
CFARGATE
DEC2
Attempts:
3 left
💡 Hint
Common Mistakes
Using EC2 launch type without EC2 instances.
Setting desired_count to zero disables the service.
5fill in blank
hard

Fill all three blanks to create a serverless API Gateway integration with Lambda.

AWS
resource "aws_api_gateway_integration" "example" {
  rest_api_id             = aws_api_gateway_rest_api.example.id
  resource_id             = aws_api_gateway_resource.example.id
  http_method             = aws_api_gateway_method.example.http_method
  integration_http_method = "[1]"
  type                    = "[2]"
  uri                     = aws_lambda_function.example.[3]
}
Drag options to blanks, or click blank then click option'
APOST
BAWS_PROXY
Cinvoke_arn
DGET
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect HTTP method for integration.
Confusing Lambda ARN property names.