📖 Scenario: You are working as a cloud architect for a small company. They want to deploy a new web application. You need to decide whether to use a serverless service like AWS Lambda or a container service like AWS Fargate. To help make this decision, you will create a simple data structure to compare the two options based on cost, scalability, and maintenance effort.
🎯 Goal: Create a dictionary with the comparison data, add a threshold for cost, filter the options based on the threshold, and finalize the decision by selecting the best option.
📋 What You'll Learn
Create a dictionary named deployment_options with exact keys and values for AWS Lambda and AWS Fargate
Add a variable named max_cost with the exact value 50
Use a dictionary comprehension named affordable_options to select options with cost less than max_cost
Add a variable named best_option that selects the option with the lowest maintenance effort from affordable_options
💡 Why This Matters
🌍 Real World
Cloud architects often need to compare different deployment methods to choose the best fit for cost, scalability, and maintenance.
💼 Career
Understanding how to structure and filter deployment options helps in making informed decisions for cloud infrastructure design.
Progress0 / 4 steps
1
Create deployment options dictionary
Create a dictionary called deployment_options with these exact entries: 'AWS Lambda': {'cost': 30, 'scalability': 9, 'maintenance': 2} and 'AWS Fargate': {'cost': 70, 'scalability': 8, 'maintenance': 5}.
AWS
Hint
Use a dictionary with keys 'AWS Lambda' and 'AWS Fargate'. Each key maps to another dictionary with keys 'cost', 'scalability', and 'maintenance'.
2
Add maximum cost threshold
Add a variable called max_cost and set it to the integer 50.
AWS
Hint
Just create a variable named max_cost and assign it the value 50.
3
Filter affordable deployment options
Create a dictionary comprehension called affordable_options that includes only the entries from deployment_options where the 'cost' is less than max_cost.
AWS
Hint
Use a dictionary comprehension with for name, details in deployment_options.items() and filter with if details['cost'] < max_cost.
4
Select best deployment option
Add a variable called best_option that selects the key from affordable_options with the lowest 'maintenance' value.
AWS
Hint
Use the min() function with a key argument to find the option with the lowest maintenance.
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
Step 1: Understand serverless concept
Serverless means you don't manage servers; code runs on demand.
Step 2: Identify AWS service matching serverless
AWS Lambda runs code without server management and scales automatically.
Final Answer:
AWS Lambda -> Option B
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
Step 1: Analyze the command
The command uses 'aws ecs create-cluster' which is for ECS clusters.
Step 2: Match command to service
ECS is AWS service for managing containers in clusters.
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
Step 1: Identify app requirements
The app runs continuously and needs custom OS settings, so it needs control over environment.
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.
Final Answer:
Amazon ECS with Fargate -> Option D
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
Step 1: Understand Lambda container support
Lambda supports container images but has a max execution time of 15 minutes.
Step 2: Identify cause of failure
If container runs longer than 15 minutes, Lambda will fail the execution.
Final Answer:
Lambda does not support running containers longer than 15 minutes -> Option A
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
Step 1: Analyze startup needs
Startup wants to minimize costs and avoid managing servers, with unpredictable traffic.
Step 2: Match AWS service to needs
AWS Lambda automatically scales with traffic and requires no server management, reducing cost and effort.
Step 3: Compare other options
ECS with EC2 or Elastic Beanstalk requires server management or fixed capacity, increasing cost and complexity.
Final Answer:
Deploy on AWS Lambda for automatic scaling and no server management -> Option A
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 unknownstrongwhile earning +1 Grip toward your certificate.