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
π Amazon EFS (Elastic File System): Scalable File Storage for Linux Instances
When working with Amazon EC2 instances, sometimes a single storage device like EBS (Elastic Block Store) is not enoughβespecially if you want multiple instances to share the same data simultaneously. This is where Amazon EFS (Elastic File System) shines.
Amazon EFS is a serverless, elastic, and scalable file storage system designed for Linux-based applications. It allows multiple EC2 instances to mount the same file system at the same time, making it perfect for content management, big data, shared apps, and DevOps workloads.
Think of Amazon EFS as a shared network drive in the cloud that automatically grows and shrinks with your data usageβwithout you worrying about provisioning storage in advance.
π What is Amazon EFS?
Amazon EFS provides fully managed network file storage that scales on demand. Unlike EBS, which is block storage attached to one instance at a time, EFS allows many instances to access the same storage concurrently using the NFS (Network File System) protocol.
Key Features of EFS:
- Shared Access β Multiple EC2 instances can mount the same EFS.
- Elastic Scaling β Automatically grows/shrinks as data changes.
- High Availability & Durability β Data is stored across multiple AZs.
- Secure β Supports encryption at rest and in transit.
- Performance Modes β General Purpose & Max I/O.
- Cost-Optimized β Pay only for what you use.
β‘ Amazon EFS Storage Classes
- Standard β Default, high-performance storage.
- Infrequent Access (IA) β Lower-cost storage for data accessed less often.
π₯οΈ Examples of Using Amazon EFS
Letβs look at three practical examples of setting up and using Amazon EFS.
β Example 1: AWS CLI β Create and Mount EFS
# Step 1: Create EFS file systemaws efs create-file-system --creation-token my-efs --performance-mode generalPurpose --throughput-mode bursting
# Step 2: Create a mount target in a VPC subnetaws efs create-mount-target --file-system-id fs-12345678 --subnet-id subnet-abc123 --security-groups sg-123456
# Step 3: Mount EFS on Linux EC2 instancesudo yum install -y amazon-efs-utilssudo mkdir /mnt/efssudo mount -t efs fs-12345678:/ /mnt/efs
π Creates an EFS file system and mounts it on an EC2 instance.
β Example 2: Python (boto3) β Automating EFS Creation
import boto3
efs = boto3.client('efs', region_name='us-east-1')
# Create EFS File Systemresponse = efs.create_file_system( CreationToken='my-efs-demo', PerformanceMode='generalPurpose', Encrypted=True)
print("Created EFS:", response['FileSystemId'])
# Create Mount Targetefs.create_mount_target( FileSystemId=response['FileSystemId'], SubnetId='subnet-abc123', SecurityGroups=['sg-123456'])
print("Mount target created successfully")
π Automates the process of creating and attaching EFS to a subnet.
β Example 3: Terraform β Provisioning EFS File System
resource "aws_efs_file_system" "example" { creation_token = "my-efs-terraform" performance_mode = "generalPurpose" encrypted = true tags = { Name = "MyEFS" }}
resource "aws_efs_mount_target" "example" { file_system_id = aws_efs_file_system.example.id subnet_id = "subnet-abc123" security_groups = ["sg-123456"]}
π Creates an EFS file system and a mount target with Terraform.
π§ How to Remember EFS for Interview & Exams
- Analogy β Think of EFS as a shared Google Drive for your Linux servers. Everyone can open and work with the same files at once.
- Mnemonic β Remember βEFS = Elastic File Sharingβ.
- Use Case Recall β If the question is about shared storage across EC2, the answer is EFS (not EBS or S3).
π― Why is Amazon EFS Important?
- Collaboration β Multiple EC2s can work on the same dataset.
- Simplicity β No need to manually provision or resize.
- High Availability β Data replicated across multiple AZs.
- Cost Efficiency β Only pay for what you use.
- DevOps Friendly β Ideal for CI/CD pipelines and containerized workloads.
π₯ Interview Questions on Amazon EFS
Q1: What is the difference between EBS and EFS? π EBS = block storage (attached to one EC2). π EFS = shared file storage (mounted by many EC2s).
Q2: Can Windows instances use EFS? π No, EFS supports Linux-based workloads only.
Q3: What protocol does EFS use? π NFSv4 (Network File System).
Q4: What are EFS performance modes? π General Purpose and Max I/O.
π Real-World Use Cases
- Web Hosting β Store and serve web content across multiple EC2s.
- Content Management Systems (CMS) β Shared storage for WordPress, Drupal.
- Big Data Analytics β Multiple compute nodes analyzing shared data.
- Machine Learning β Training models on shared datasets.
- DevOps Pipelines β CI/CD builds needing shared file storage.
π Best Practices for EFS
- Use Mount Targets in All AZs β For high availability.
- Enable Encryption β Protect sensitive data with AWS KMS.
- Monitor Costs β Use EFS Infrequent Access for less-used data.
- Optimize Performance β Choose Max I/O for big data workloads.
- Integrate with Containers β Use with Amazon EKS or ECS.
π Conclusion
Amazon EFS is a game-changer for shared storage in AWS. It provides scalable, serverless, and elastic file storage that can be mounted by multiple Linux-based EC2 instances at the same time.
If you think about AWS storage options:
- EBS β Single-instance storage (like a hard drive).
- S3 β Object storage for static files.
- EFS β Shared file system for Linux applications.
π To remember: EFS = Shared Google Drive for EC2 instances.
By mastering EFS, you enhance your AWS expertise, prepare for certifications, and gain the ability to design scalable cloud-native applications.