1.3.10 Storage Services (S3, EBS, EFS)

Storage Services cho Developer

So sánh S3 vs EBS vs EFS

FeatureS3EBSEFS
TypeObject storageBlock storageFile storage (NFS)
AccessHTTP/HTTPS APISingle EC2 instance (hoặc multi-attach io2)Multiple EC2/Lambda/ECS
Durability99.999999999% (11 9s)99.999%99.999999999%
ScalingUnlimitedFixed size (provision)Auto-scaling
Use caseStatic assets, backups, data lakeEC2 boot volumes, databasesShared file system
Lambda support✅ SDK access✅ Mount as local filesystem

Amazon EFS (Elastic File System)

Lambda + EFS Integration

Lambda Function → VPC → EFS Mount Target → EFS File System
                  (same VPC, private subnets)
  • Lambda mount EFS as local filesystem (/mnt/efs)
  • Shared storage giữa multiple Lambda functions
  • Use cases: ML models, shared config, large reference data
# SAM template
MyFunction:
  Type: AWS::Serverless::Function
  Properties:
    VpcConfig:
      SecurityGroupIds: [!Ref LambdaSG]
      SubnetIds: [!Ref PrivateSubnet1, !Ref PrivateSubnet2]
    FileSystemConfigs:
      - Arn: !GetAtt EFSAccessPoint.Arn
        LocalMountPath: /mnt/data

EFS Access Points

  • Application-specific entry points
  • Enforce user identity (POSIX UID/GID)
  • Root directory per application
  • IAM-based access control

Performance Modes

ModeUse Case
General PurposeLow latency, most workloads
Max I/OHigh throughput, parallel access

Throughput Modes

ModeMô tả
BurstingScales with file system size
ProvisionedFixed throughput regardless of size
ElasticAuto-scales throughput (recommended)

Storage Classes

ClassMô tả
StandardFrequently accessed
Infrequent Access (IA)Lower cost, retrieval fee
ArchiveLowest cost, rarely accessed
  • Lifecycle policies tự động move files giữa classes

Amazon EBS (Elastic Block Store)

Volume Types cho Developer

TypeUse CaseIOPS
gp3General purpose (default)3,000 baseline, up to 16,000
io2High-performance databasesUp to 64,000
st1Throughput-optimized (big data)N/A (throughput-based)

Key Points cho Exam

  • EBS volumes attached to single EC2 instance (same AZ)
  • Snapshots → S3 (incremental, cross-region copy)
  • Encryption: AWS managed hoặc CMK
  • Multi-Attach (io2 only): multiple EC2 in same AZ

Amazon S3 cho Developer

Key Features

FeatureMô tả
Pre-signed URLsTemporary access without AWS credentials
S3 SelectQuery data in-place (CSV, JSON, Parquet)
Event NotificationsTrigger Lambda, SQS, SNS, EventBridge
Transfer AccelerationFast upload via CloudFront edge
Multipart UploadLarge files (> 100MB recommended)
# Pre-signed URL (temporary access)
import boto3
s3 = boto3.client('s3')
url = s3.generate_presigned_url('get_object',
    Params={'Bucket': 'my-bucket', 'Key': 'file.pdf'},
    ExpiresIn=3600  # 1 hour
)

Exam Tip: Lambda + shared storage = EFS (mount as filesystem). Large objects = S3. EC2 boot/database volumes = EBS. EFS cần Lambda trong VPC. Pre-signed URLs cho temporary S3 access. S3 Select giảm data transfer.