Bird
Raised Fist0
AWScloud~10 mins

Serverless vs container decision in AWS - Interactive Practice

Choose your learning style10 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.

Practice

(1/5)
1. Which AWS service lets you run code without managing servers, automatically scaling with demand?
easy
A. Amazon ECS
B. AWS Lambda
C. Amazon EC2
D. AWS Elastic Beanstalk

Solution

  1. Step 1: Understand serverless concept

    Serverless means you don't manage servers; code runs on demand.
  2. Step 2: Identify AWS service matching serverless

    AWS Lambda runs code without server management and scales automatically.
  3. Final Answer:

    AWS Lambda -> Option B
  4. Quick Check:

    Serverless = AWS Lambda [OK]
Hint: Serverless means no servers to manage, pick Lambda [OK]
Common Mistakes:
  • Choosing EC2 which requires server management
  • Confusing containers with serverless
  • Picking Elastic Beanstalk which manages servers but not fully serverless
2. Which AWS service is best described by this syntax snippet for deploying a container?
aws ecs create-cluster --cluster-name myCluster
easy
A. Amazon S3 bucket creation
B. AWS Lambda function deployment
C. Amazon ECS container cluster creation
D. AWS CloudFormation stack deployment

Solution

  1. Step 1: Analyze the command

    The command uses 'aws ecs create-cluster' which is for ECS clusters.
  2. Step 2: Match command to service

    ECS is AWS service for managing containers in clusters.
  3. Final Answer:

    Amazon ECS container cluster creation -> Option C
  4. Quick Check:

    "aws ecs create-cluster" = ECS container cluster [OK]
Hint: ECS commands manage containers, Lambda uses different syntax [OK]
Common Mistakes:
  • Thinking this command deploys Lambda functions
  • Confusing S3 bucket commands with ECS
  • Assuming CloudFormation syntax
3. You have a web app that needs to run continuously with custom OS settings. Which AWS option fits best?
Options:
A) AWS Lambda
B) AWS CloudFront
C) Amazon S3
D) Amazon ECS with Fargate
medium
A. AWS Lambda
B. AWS CloudFront
C. Amazon S3
D. Amazon ECS with Fargate

Solution

  1. Step 1: Identify app requirements

    The app runs continuously and needs custom OS settings, so it needs control over environment.
  2. Step 2: Match service to requirements

    AWS Lambda is event-driven and short-lived, not continuous. ECS with Fargate runs containers continuously with environment control.
  3. Final Answer:

    Amazon ECS with Fargate -> Option D
  4. Quick Check:

    Continuous app + custom OS = ECS Fargate [OK]
Hint: Continuous with custom OS? Choose containers (ECS) not Lambda [OK]
Common Mistakes:
  • Choosing Lambda for continuous workloads
  • Confusing S3 (storage) or CloudFront (CDN) as compute
  • Ignoring environment control needs
4. You tried running a container on AWS Lambda but it failed. What is the likely cause?
medium
A. Lambda does not support running containers longer than 15 minutes
B. Lambda requires a Dockerfile to deploy containers
C. Lambda only supports Python code, not containers
D. Lambda cannot run containers at all

Solution

  1. Step 1: Understand Lambda container support

    Lambda supports container images but has a max execution time of 15 minutes.
  2. Step 2: Identify cause of failure

    If container runs longer than 15 minutes, Lambda will fail the execution.
  3. Final Answer:

    Lambda does not support running containers longer than 15 minutes -> Option A
  4. Quick Check:

    Lambda container max time = 15 minutes [OK]
Hint: Lambda containers have 15-minute max runtime limit [OK]
Common Mistakes:
  • Thinking Lambda cannot run containers at all
  • Believing Lambda only supports Python code
  • Confusing Dockerfile requirement
5. Your startup wants to minimize costs and avoid managing servers for a new app with unpredictable traffic spikes. Which AWS approach is best?
hard
A. Deploy on AWS Lambda for automatic scaling and no server management
B. Use Amazon ECS with EC2 instances for full control
C. Host on Amazon EC2 with manual scaling
D. Use AWS Elastic Beanstalk with fixed server capacity

Solution

  1. Step 1: Analyze startup needs

    Startup wants to minimize costs and avoid managing servers, with unpredictable traffic.
  2. Step 2: Match AWS service to needs

    AWS Lambda automatically scales with traffic and requires no server management, reducing cost and effort.
  3. Step 3: Compare other options

    ECS with EC2 or Elastic Beanstalk requires server management or fixed capacity, increasing cost and complexity.
  4. Final Answer:

    Deploy on AWS Lambda for automatic scaling and no server management -> Option A
  5. Quick Check:

    Min cost + no servers + spikes = Lambda [OK]
Hint: No servers + spikes? Pick Lambda for auto scaling [OK]
Common Mistakes:
  • Choosing ECS or EC2 which need server management
  • Assuming Elastic Beanstalk auto-scales without servers
  • Ignoring cost and management factors
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard