Getting started with Amazon Elastic File System
Getting started with Amazon Elastic File System
File System
Amazon EFS is a simple, serverless, elastic, set-and-forget le system that automatically grows
and shrinks as you add and remove les with no need for management or provisioning. You can
use Amazon EFS with Amazon EC2, AWS Lambda, Amazon ECS, Amazon EKS and other AWS
compute instances, or with on-premises servers.
In this getting started exercise, you can learn how to quickly create an Amazon Elastic File
System (Amazon EFS) le system. As part of this process, you mount your le system on two
Amazon Elastic Compute Cloud (Amazon EC2) instances in your virtual private cloud (VPC). You
also test the end-to-end setup.
Steps
Following are the steps to be performed to complete this exercise:
2. In the navigation bar at the top of the screen, the current AWS Region is displayed (for
example, US East (N.Virginia)). Select a Region in which to deploy your resources including
your EFS le system and EC2 instances.
Page 1 of 17
fi
fi
fi
fi
fi
fi
fi
fi
3. Choose Create le system to open the Create le system dialog box.
5. For Virtual Private Cloud (VPC), choose your VPC, or keep it set to your default VPC.
• Regional to create a le system that uses Standard storage classes. Standard storage classes
store le system data and metadata redundantly across all Availability Zones within an AWS
Region. Regional o ers the highest levels of availability and durability.
• One Zone to create a le system that uses One Zone storage classes. One Zone storage
classes store le system data and metadata redundantly within a single Availability Zone which
makes it less expensive than Standard storage classes.
Because EFS One Zone storage classes store data in a single AWS Availability Zone, data stored
in these storage classes may be lost in the event of a disaster or other fault that a ects all copies
of the data within the Availability Zone, or in the event of Availability Zone destruction resulting
from disasters, such as earthquakes and oods. If you choose One Zone, choose the Availability
Zone that you want the le system created in, or leave the default setting.
Page 2 of 17
fi
fi
fi
ff
fi
fi
fi
fi
fl
fi
ff
7. Choose Create to create a le system.
8. The File systems page appears with a banner across the top showing the status of the le
system you created. A link to access the le system details page appears in the banner when the
le system becomes available. Click View le system.
Page 3 of 17
fi
fi
fi
fi
fi
9. Within Network, you can see the number of mount targets created automatically. By default,
this deployment will create a mount target in each Availability Zone in the AWS Region.
A mount target provides an IP address for an NFSv4 endpoint at which you can mount an Amazon
EFS le system. You mount your le system using its Domain Name Service (DNS) name, which
resolves to the IP address of the EFS mount target in the same Availability Zone as your EC2
instance. You can create one mount target in each Availability Zone in an AWS Region. If there are
multiple subnets in an Availability Zone in your VPC, you create a mount target in one of the
subnets. Then all EC2 instances in that Availability Zone share that mount target.
An Amazon EFS file system can only have mount targets in one VPC at a time.
Mount targets themselves are designed to be highly available. As you design for high availability
and failover to other Availability Zones, keep in mind that while the IP addresses and DNS for your
mount targets in each Availability Zone are static, they are redundant components backed by
multiple resources.
Page 4 of 17
fi
fi
Launch two Amazon Linux EC2 instances
In this step you will create two new Amazon EC2 instances running Amazon Linux 2, and
con gure it to automatically mount the EFS le system you just created in the previous step.
10. Navigate to EC2 console by searching for EC2 on the top in the search bar and clicking on the
presented option.
11. From the Amazon EC2 console dashboard, choose Launch instance
Page 5 of 17
fi
fi
12. For Name, enter a descriptive name for the instances.
13. Under Application and OS Images (Amazon Machine Image), choose Quick Start, and
then choose the Amazon Linux 2 AMI (HVM) - Kernel 5.10, SSD Volume Type for your instance.
14. For Instance type, select either the t2.micro or t3.micro instance type (depending on the
availability) for the instance.
Page 6 of 17
15. For Key pair name, choose an existing key pair, or choose Create new key pair to create a
new one.
• For Name, enter a descriptive name for the key pair. Amazon EC2 associates the public key
with the name that you specify as the key name. A key name can include up to 255 ASCII
characters. It can’t include leading or trailing space
Page 7 of 17
fi
• The private key le is automatically downloaded by your browser. The base le name is the
name that you speci ed as the name of your key pair, and the le name extension is
determined by the le format that you chose. Save the private key le in a safe place.
16. To con gure some of the network settings, click Edit in Network settings section.
• Network: Here the default VPC is selected automatically. You will be launching this EC2
instance in the same default VPC of the region you’re working in.
• Subnet: Select any of the available subnets linked to any speci c availability zone. This is an
important step to be performed before you can add a le system.
• Auto-assign Public IP: Specify whether your instance receives a public IPv4 address. By
default, instances in a default subnet receive a public IPv4 address, and instances in a non-
default subnet don't. You can select Enable or Disable to override the subnet's default setting.
For this hands-on, keep Auto-assign public IP to Enable.
Page 8 of 17
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
A. Keep the VPC set to default.
18. Use a security group to de ne rewall rules for your instance. These rules specify which
incoming network tra c is delivered to your instance. All other tra c is ignored. Create a new
security group which allows inbound SSH access from a known IP address.
Page 9 of 17
ffi
fi
fi
ffi
19. Within Con gure storage, click Edit to mount the EFS le system to the instances.
20. Select EFS within File systems, and then click Add shared le system.
Page 10 of 17
fi
fi
fi
21. Ensure that the value matches the le system ID that you created in the previous step. The
path shown next to the le system ID is the mount point that the instance will use, which you can
change.
Note that upon adding the shared le system following actions will be performed automatically:
• Another security group will be created and attached to the instances, which will allow inbound
NFS connections to the le system via the EFS mount target from the EC2 instances that are
associated with this security group (the source is the security group itself).
• Under Advanced Details, the User data is automatically generated, and includes the
commands needed to mount the le system.
Hence, you should ensure that options Automatically create and attach security groups and
Automatically mount shared le system by attaching required user data script remain
selected.
Page 11 of 17
fi
fi
fi
fi
fi
fi
22. Within Summary, mention 2 for the Number of instances and click Launch instance. This
will allow you to create two Amazon EC2 Linux instances while adding the shared EFS le system
to them.
23. The EC2 instances will now be successfully launched. Click View all instances to view and
access these newly launched EC2 instances on the instance dashboard.
24. The newly launched Amazon EC2 linux instances will be displayed as follows. Initially, their
status is pending. After the status changes to running, your instances are ready for use.
Page 12 of 17
fi
Your instances are now con gured to mount the Amazon EFS le system at launch and whenever
they’re rebooted.
25. Connect to your instances. Initiate an SSH connection to these Amazon EC2 Linux instances.
Page 13 of 17
fi
fi
fi
fi
fi
fi
26. From the terminal window for each instance, run the df -T command to verify that the EFS le
system is mounted.
27. Create a le in the le system from one instance, and then verify that you can view the le
from the other instance.
• From the rst instance, run the following command to create the le.
Page 14 of 17
fi
fi
fi
fi
fi
fi
fi
• From the second instance, run the following command to view the le.
ls /mnt/efs/fs1
Clean up
When you are nished with this tutorial, you can terminate the instances and delete the le
system.
28. Go back to EC2 dashboard, choose Instances from the navigation pane and then select the
instances to terminate.
Page 15 of 17
fi
fi
fi
29. Choose Instance state, Terminate instance.
31. Open the Amazon Elastic File System console and select the le system to delete, and click
Delete.
Page 16 of 17
fi
fi
fi
32. When prompted for con rmation, enter the le system ID and choose Con rm.
Summary
This completes the hands-on exercise on creating an EFS le system and mounting it on two
Amazon Elastic Compute Cloud (Amazon EC2) instances in your virtual private cloud (VPC). You
then tested the end-to-end setup by creating a le in the le system from one instance, and then
veri ed that you can view the le from the other instance.
After testing, resources including both EC2 instances and EFS le system were terminated to
clean up and avoid any unexpected charges.
Page 17 of 17
fi
fi
fi
fi
fi
fi
fi
fi
fi