DEMO: Implementing a Basic EFS
Ref: https://learn.cantrill.io/courses/1820301/lectures/41301665 and https://learn.cantrill.io/courses/1820301/lectures/41301666
- 💡 In this demo, we create an EFS file system that is deployed in a custom VPC
- Use the same EFS settings as in the video
- đź”§Â It is best practice to put a mount target in every AZ where a resource will consume EFS
- Every mount target needs an attached SG - Screenshot:
Configuring an EC2 Instance to Use EFS
- 💡 We run these commands inside an EC2 instance
df -k
— List all mounted FSs in the Linux OS (we can see there is no EFS file system yet)
- ”disk free” → displays the available disk space in each of the partitions in the system
-k
→ show available space in kB
sudo mkdir -p /efs/wp-content
— Make a directory with specified path and name
-p
→ the specified path will be created if it doesn't already exist
sudo dnf -y install amazon-efs-utils
— Install a package of tools to interact with EFS
-y
→ acknowledges (”yes”) all prompts
sudo nano /etc/fstab
— Open FSTAB file to edit it
- đź”§Â FSTAB file contains info of all FSs that will be mounted when the instance (re)boots
- Add this line at EOF:
<file-system-id>:/ /efs/wp-content efs _netdev,tls,iam 0 0
- âť—Â Substitute
<file-system-id>
with the ID of the FS in EFS!
sudo mount /efs/wp-content
— Mount the specified directory according to the FSTAB file configuration
df -k
— We can now see that the EFS file system is mounted in the instance
- 💡 Now that the system is mounted, we can navigate to
/efs/wp-content
and e.g. add a file
- That file is in the EFS file system
- If we configure a different EC2 instance in the VPC to access the same EFS file system, we will be able to access the same file → shared NW file system
WordPress Architecture with EFS
Ref: https://learn.cantrill.io/courses/1820301/lectures/41301667
- A new step of moving the architecture from a monolith to being fully elastic and resilient
- Local FS is no longer critical, it no longer stores WordPress media uploaded to posts
- Both instances access the same content/data, which is stored in RDS and in EFS
- We can scale horizontally (up or down) according to system load, increasing or decreasing the number of EC2 instances. There can be 1, 2, or 200 instances.