Amazon EFS: Fully Managed File Storage for EC2

Amazon EFS: Fully Managed File Storage for EC2

Amazon Elastic File System (EFS) is a fully managed cloud-native file system that makes it easy to set up shared file storage for EC2 instances. EFS allows you to create scalable file systems that can be accessed concurrently from multiple EC2 instances. This makes EFS a great fit for lifting and shifting applications to the cloud that require shared file access as well as new cloud-native applications that need shared storage.

In this tutorial, we will walk through how to create an EFS file system, mount it to an EC2 instance, manage permissions and encryption, and access the storage from your application code. EFS handles all the storage management tasks like replication, scaling capacity, server management, and backups for you. All you have to do is create the file system, mount it, and start using it.

We will cover how to get started with EFS using the AWS Management Console as well as the AWS Command Line Interface. By the end, you will understand how to deploy EFS as a simple, scalable shared file system for your EC2 workloads. The native integration of EFS with EC2 makes it straightforward to get started. Let’s dive in and see how EFS can provide your instances with dynamic, shared file storage.

Benefits of Using EFS

Amazon Elastic File System (EFS) provides several key benefits that make it an attractive fully managed file storage option for EC2 instances.

First, EFS is a fully managed service, so you do not have to provision or manage any file servers yourself. The service takes care of all the undifferentiated heavy lifting involved in storage management. All you have to do is create the file system, mount it on your EC2 instances, and start using it.

In addition, EFS scales automatically as you add more files without any intervention needed on your part. You don’t have to pre-provision any storage capacity or manage how much data you write to the file system. The service grows and shrinks automatically as your workload demands. This autoscaling capability also means you only pay for the storage you actually use each month.

EFS file systems are designed to be highly available and durable by replicating data across multiple Availability Zones (AZs) automatically. This prevents data loss due to failures in a single AZ.

The service is also designed specifically to work seamlessly with Linux-based EC2 instances in an Amazon Virtual Private Cloud (VPC). The file system access works just like any NFS mount, making EFS easy to integrate with your EC2 workloads.

Finally, EFS offers robust data encryption, both at rest and in transit. You can ensure your sensitive file data is protected end-to-end.

In summary, with automatic scaling, high availability, tight EC2 integration, encryption, and no servers to manage yourself, EFS makes it easy to deploy shared file storage for your EC2 applications.

Creating an EFS File System

To create a new EFS file system:

  1. Open the Amazon EFS console
  2. Click “Create file system”
  3. Specify a name for the file system
  4. Select the VPC you want to launch the file system in
  5. Customize the network access settings as needed (usually default is fine)
  6. Click “Next” and review the settings
  7. Click “Create” to launch the EFS file system

The new file system will be available in a few moments.

Mounting the EFS File System on an EC2 Instance

To mount the EFS file system on an EC2 instance:

  1. Launch an EC2 instance in the same VPC as the EFS file system
  2. Connect to the EC2 instance (e.g. via SSH)
  3. Install the Amazon EFS utils package:
  4. Create a directory to mount the EFS file system on:
  5. Mount the EFS file system to the directory:
  6. The EFS file system is now mounted and available under the efs/ directory

Any files written to the efs/ directory will be persisted in the EFS file system storage. The file system can be mounted to multiple EC2 instances simultaneously.

EFS Performance and Storage Classes

EFS offers two storage classes:

  • Standard — for frequently accessed files
  • Infrequent Access (EFS IA) — cost-optimized storage for files not accessed often

For best performance, use EFS Standard storage and provision your EC2 instances to have sufficient network bandwidth and IOPS for your workload.

Scaling and Availability

EFS file systems are highly available by default, with data replicated across multiple Availability Zones. You can create read replicas of your EFS file systems for enhanced performance. EFS scales automatically — there is no need to provision storage capacity ahead of time. You only pay for the storage you use. This covers the basics of creating and using an EFS file system with EC2. EFS provides a simple, scalable shared file system for EC2 applications and workloads.

AWS CLI Commands for EFS

Here are some example AWS CLI commands for working with EFS:

Create a new EFS file system

List your EFS file systems

Create an EFS mount target

Get mount target DNS name

Mount EFS file system on EC2 instance

List directories in EFS

Delete EFS file system

The AWS CLI provides a complete set of commands for creating, managing, and deleting EFS file systems programmatically. Refer to the AWS CLI documentation for more details.

Conclusion

Amazon Elastic File System provides a managed, scalable file storage service that makes it easy to set up shared file access for your EC2 instances. With EFS, you can create NFS file systems that can be mounted to multiple instances simultaneously without the need to provision file servers yourself.

We walked through creating an EFS file system, mounting it on an EC2 instance, and accessing the shared storage from your application code. EFS handles all of the undifferentiated heavy lifting of storage management like capacity scaling, redundancy, and server management automatically.

The ability to mount the same file system across multiple instances is powerful for both lifting and shifting existing applications as well as building new cloud-native applications. EFS storage grows and shrinks automatically as you add and remove files so you don’t have to worry about managing capacity.

EFS is highly available, encrypts your data at rest and in transit, and provides options like Infrequent Access storage class for less frequently accessed data. The native integration with EC2 makes it fast and easy to get started.

In summary, if you need fully managed shared file storage for your EC2 environment, EFS is a simple, scalable solution. You can be up and running in minutes and avoid the overhead of managing file servers yourself. Give EFS a try for your next EC2 workload requiring shared file access.

Previous Post Next Post