Amazon Web Services
Compute
- AWS EC2
- EC2 Instance Types
- EC2 Pricing Models
- EC2 Auto Scaling
- Elastic Load Balancing-ELB
- AWS Lambda – Serverless Computing
- Amazon Lightsail
- AWS Elastic Beanstalk
- AWS Fargate
- Amazon ECS (Elastic Container Service)
- Amazon EKS (Elastic Kubernetes Service)
DynamoDB
- DynamoDB Global Table vs Regular DynamoDB Table
- DynamoDB Streams
- Athena query data to DynamoDB
- Athena Query Results with DynamoDB
- PySpark DataFrame to DynamoDB
Redshift
Lambda
Glue
Lambda
Storage
- S3 vs. EBS vs. EFS
- Amazon S3 (Simple Storage Service)
- Amazon S3 Storage Classes
- Amazon EBS (Elastic Block Store)
- Amazon EFS (Elastic File System)
- AWS Storage Gateway
- AWS Snowball
- Amazon FSx
- AWS Backup
Security
🚀 AWS Fargate – Serverless Compute for Containers
Containers have become the backbone of modern application deployment. They are lightweight, portable, and scalable. But managing container infrastructure is complex—think about provisioning EC2 instances, patching OS, scaling clusters, and securing workloads.
👉 That’s where AWS Fargate comes in.
AWS Fargate is a serverless compute engine for containers that works with Amazon ECS (Elastic Container Service) and Amazon EKS (Elastic Kubernetes Service).
With Fargate:
- You don’t manage servers.
- You define container CPU, memory, and networking.
- AWS runs containers for you, scaling automatically.
It’s like Lambda for containers—you focus on your app, not infrastructure.
🔑 What is AWS Fargate?
AWS Fargate is a serverless container orchestration service.
- Works with ECS and EKS.
- Eliminates need to manage EC2 clusters for containers.
- Provides on-demand scaling.
- Billing is based on CPU & memory requested per container task.
Benefits:
- No Infrastructure Management → No EC2 provisioning.
- Seamless Scaling → Runs containers across multiple AZs.
- Cost-Efficient → Pay only for resources used.
- Security → Isolation per task (each container runs in its own kernel).
- Integration → Works with IAM, VPC, CloudWatch, ALB/NLB.
⚙️ Core Concepts of AWS Fargate
-
Task Definition → Blueprint for containers (image, CPU, memory, env vars).
-
Task → A running instance of a task definition.
-
Service → Ensures desired tasks stay running (like deployment).
-
Cluster → Logical grouping of services/tasks.
-
Launch Type → ECS supports two:
- EC2 → You manage instances.
- Fargate → AWS manages everything (serverless).
📌 Example 1: Running ECS Task on Fargate
Here’s how you run a simple container using Fargate with ECS.
Python (boto3) Example
import boto3
ecs = boto3.client('ecs')
response = ecs.run_task( cluster='my-fargate-cluster', launchType='FARGATE', taskDefinition='nginx-task', count=1, networkConfiguration={ 'awsvpcConfiguration': { 'subnets': ['subnet-123456'], 'assignPublicIp': 'ENABLED' } })
print("Task Started:", response)
AWS CLI Example
aws ecs run-task \ --cluster my-fargate-cluster \ --launch-type FARGATE \ --task-definition nginx-task \ --network-configuration "awsvpcConfiguration={subnets=[subnet-123456],assignPublicIp=ENABLED}" \ --count 1
Node.js Example
const AWS = require('aws-sdk');const ecs = new AWS.ECS();
ecs.runTask({ cluster: 'my-fargate-cluster', launchType: 'FARGATE', taskDefinition: 'nginx-task', count: 1, networkConfiguration: { awsvpcConfiguration: { subnets: ['subnet-123456'], assignPublicIp: 'ENABLED' } }}, (err, data) => { if (err) console.error(err); else console.log("Task Started:", data);});
👉 This example launches a containerized Nginx server on Fargate.
📌 Example 2: Creating a Service on Fargate
Instead of a single task, you can create a service that ensures your app runs continuously.
Python Example
response = ecs.create_service( cluster='my-fargate-cluster', serviceName='web-service', taskDefinition='nginx-task', desiredCount=2, launchType='FARGATE', networkConfiguration={ 'awsvpcConfiguration': { 'subnets': ['subnet-123456'], 'assignPublicIp': 'ENABLED' } })print("Service Created:", response)
AWS CLI Example
aws ecs create-service \ --cluster my-fargate-cluster \ --service-name web-service \ --task-definition nginx-task \ --desired-count 2 \ --launch-type FARGATE \ --network-configuration "awsvpcConfiguration={subnets=[subnet-123456],assignPublicIp=ENABLED}"
Node.js Example
ecs.createService({ cluster: 'my-fargate-cluster', serviceName: 'web-service', taskDefinition: 'nginx-task', desiredCount: 2, launchType: 'FARGATE', networkConfiguration: { awsvpcConfiguration: { subnets: ['subnet-123456'], assignPublicIp: 'ENABLED' } }}, (err, data) => { if (err) console.error(err); else console.log("Service Created:", data);});
👉 This ensures 2 replicas of your app are always running.
📌 Example 3: Running Fargate with EKS (Kubernetes)
AWS Fargate also supports Kubernetes pods using EKS.
Python Example – EKS Fargate Profile
import boto3
eks = boto3.client('eks')
response = eks.create_fargate_profile( clusterName='my-eks-cluster', fargateProfileName='my-fargate-profile', podExecutionRoleArn='arn:aws:iam::123456789012:role/AmazonEKSFargatePodExecutionRole', selectors=[{ 'namespace': 'default' }], subnets=['subnet-123456'])
print("Fargate Profile Created:", response)
AWS CLI Example
aws eks create-fargate-profile \ --cluster-name my-eks-cluster \ --fargate-profile-name my-fargate-profile \ --pod-execution-role-arn arn:aws:iam::123456789012:role/AmazonEKSFargatePodExecutionRole \ --subnets subnet-123456 \ --selectors namespace=default
Node.js Example
const eks = new AWS.EKS();
eks.createFargateProfile({ clusterName: 'my-eks-cluster', fargateProfileName: 'my-fargate-profile', podExecutionRoleArn: 'arn:aws:iam::123456789012:role/AmazonEKSFargatePodExecutionRole', subnets: ['subnet-123456'], selectors: [{ namespace: 'default' }]}, (err, data) => { if (err) console.error(err); else console.log("Fargate Profile Created:", data);});
👉 This allows running Kubernetes pods on Fargate without EC2 worker nodes.
🧠 How to Remember AWS Fargate for Interview/Exam
💡 Trick: F-A-R-G-A-T-E = Focused Applications Run Globally, Abstracting The EC2
- F → Fargate
- A → Applications
- R → Run
- G → Globally
- A → Abstracting
- T → The
- E → EC2 layer
👉 Memory Hook: “Fargate abstracts EC2 while running apps globally.”
Common Exam Questions:
-
Difference between ECS EC2 vs ECS Fargate?
- EC2 → You manage servers.
- Fargate → AWS manages servers.
-
Can Fargate run on EKS? → Yes.
-
How is Fargate billed? → Per vCPU & memory requested.
🎯 Why AWS Fargate is Important
- Serverless for Containers → Removes EC2 management.
- Consistency → Same behavior in dev, test, prod.
- Security → Each task isolated, unlike EC2 shared cluster.
- Scalability → Auto scales containers based on load.
- Cost Efficiency → Pay only for allocated CPU & memory.
- Future-Ready → Serverless containers are the next big thing in cloud.
🌍 Real-World Use Cases
- Microservices → Deploy containerized microservices with zero server management.
- Batch Processing → Run batch jobs serverlessly with Fargate tasks.
- Web APIs → Scale REST APIs automatically with Fargate.
- Kubernetes Pods → Run EKS workloads without worker nodes.
📌 Conclusion
AWS Fargate is a game-changer in container orchestration.
- No more EC2 cluster management.
- Works with ECS & EKS seamlessly.
- Pay only for what you use.
- Perfect for microservices, APIs, and modern apps.
👉 Remember F-A-R-G-A-T-E → “Focused Applications Run Globally, Abstracting The EC2.”
If you’re preparing for AWS exams or interviews, always link Fargate to serverless containers and per-task billing.