Part 1 - The S3 Files EC2 Infrastructure Handbook Manual Configuration & Architecture
Rantideb Howlader••7 min read•
By Rantideb Howlader
Introduction
Amazon S3 Files allows you to mount S3 buckets as standard NFS v4.1 file systems. Unlike previous FUSE-based solutions, this is a managed gateway service that provides high-performance, concurrent access across EC2, Lambda, and ECS.
This manual documents the precise steps required to engineer an S3-backed file system on Linux (Amazon Linux 2023), from initial VPC setup to final protocol verification.
Architecture: The VPC NFS Gateway
S3 Files operates through Mount Targets within your VPC. Your compute resources connect to these targets via standard NFS (Port 2049), which then orchestrates the object-to-file translation.
Allows S3 to notify the gateway of object changes.
S3 Objects
s3:GetObject, s3:PutObject, s3:DeleteObject
Data I/O
Events
events:PutRule, events:PutTargets
Must target DO-NOT-DELETE-S3-Files* with events:ManagedBy condition.
KMS Key
kms:GenerateDataKey, kms:Decrypt
Data Encryption (Optional)
[!IMPORTANT]
KMS Nuance: If using a Customer Managed Key (CMK), you MUST include a Condition block in your policy that limits the key usage to the S3 service via kms:ViaService = "s3.REGION.amazonaws.com".
B. Compute Client Role (EC2)
Your EC2 instance requires an Instance Profile containing the AmazonS3FilesClientFullAccess managed policy.
Managed Policy
Purpose
AmazonS3FilesClientFullAccess
Allows the kernel to negotiate with the gateway
AmazonSSMManagedInstanceCore
Required for secure management via SSM Session Manager
Phase 2: File System & Client Setup
1. Create the S3 Files File System
Register the file system through the AWS CLI v2.34.26+ or the AWS Console.
[!NOTE]
Transient Console Error: While the file system is in the Creating state, the AWS Console may display an "Unknown Error" in the Synchronization configuration panel. This is often transient and should clear once the status reaches available. If it persists, re-verify your IAM File System role trust policy.
2. Deploy Mount Targets
You must create a mount target in each Subnet (Availability Zone) where your EC2 instances reside.
[!IMPORTANT]
AZ Alignment: Your EC2 instance must reside in a subnet that is in the same Availability Zone as at least one S3 Files mount target to ensure high-performance NFS discovery.
3. Install the NFS Helper (Amazon Linux 2023)
The mount process requires amazon_efs_utils version 3.0.x or later. Ensure your instance has reachability to Amazon Linux package mirrors (via IGW or NAT).
# Update local packagessudo dnf update -y# Install the mount helpersudo dnf install -y amazon-efs-utils
Phase 3: Mounting & Persistence
1. Execute the Mount
Create a local directory and mount the file system using the native s3files type.
# Prepare the mount pointsudo mkdir -p /mnt/s3filessudo chmod 755 /mnt/s3files# Mount by File System ID with root-path syntaxsudo mount -t s3files fs-0123456789abcdef0:/ /mnt/s3files
[!TIP]
Production Note: Permission Persistence
S3 Files mount roots often revert to root-only ownership. To allow ec2-user or ssm-user to access the volume without sudo after a reboot, create a systemd service to re-apply permissions:
Perform these steps inside the instance to confirm protocol integrity:
IMDSv2 Check: Ensure the instance has http_put_response_hop_limit = 2 set in its metadata options; without this, the gateway sync agent may fail to retrieve tokens.
Protocol Check: findmnt -T /mnt/s3files — FSTYPE must show s3files.
Mount Context: df -h /mnt/s3files — Verify the size is listed as 8.0E (Exabytes).
S3 Consistency: aws s3 ls s3://BUCKET/verify.txt — Confirm the object appears in the bucket after a few seconds.
Phase 5: Resource Teardown (Cleanup)
To avoid orphaned costs and ENIs, follow this strict deletion sequence:
Unmount: sudo umount /mnt/s3files.
De-schedule Compute: Shut down EC2 instances using the file system.
Delete Mount Targets: Remove all targets across AZs.
Delete File System: aws s3files delete-file-system --file-system-id FS_ID. Note: The API will reject this command if any mount target remains in the deleting state. Wait for them to fully terminate.
Security Groups: Delete the Mount Target Security Group.
Phase 6: Common Engineering Hurdles & Troubleshooting
Even with correct configuration, S3 Files can encounter operational issues in complex VPC environments.
Cause: Unsupported bucket encryption type (SSE-C or DSSE-KMS).
Fix: S3 Files explicitly does not support SSE-C (customer-provided keys) or DSSE-KMS. You must configure your bucket with standard SSE-S3 (AES256) or regular SSE-KMS (aws:kms).
2. Error: mount.s3files: command not found
Cause: The amazon-efs-utils version is below 3.0.x.
Fix: Run yum list installed amazon-efs-utils and ensure the version is 3.x. Update via dnf install -y amazon-efs-utils.
3. Error: mount.nfs4: Connection timed out
Cause: Security Group or Routing failure.
Fix: Verify TCP Port 2049 is open inbound on the Mount Target SG. Note: If the mount hangs for more than 60 seconds, it is a confirmed timeout; standard latency is typically 10–30s.
4. Error: Permission Denied during mount
Cause: IAM Role misconfiguration or missing Versioning on the bucket.
Fix: Check the SourceArn. Nuance: Ensure the instance is using a supported kernel—the definitive filter is al2023-ami-*-kernel-*-x86_64.
5. Symptom: Files written on EC2 do not appear in S3 immediately
Root Cause: S3 Files uses an asynchronous metadata engine for high-performance I/O.
Verification: Wait 5–10 seconds for the EventBridge sync rule to trigger. For large batch writes, the delay may scale based on the metadata churn.
The Lambda Handbook (Part 2) continues with Access Point logic and serverless persistence.