How to Mount a Persistent Volume for App Data in Amazon AWS ECS Service
If you are upgrading your service or restarting your container, it might lead to data loss in the BoldReports application, which is deployed in the Amazon AWS ECS service. To avoid this, we suggest you mount a persistent volume for app data. This article explains how to mount app data in EFS storage while deploying and how to access the app_data in the EFS file storage through a Linux VM.
- VPC must be the same for both EFS and ECS (including creating services or tasks).
- Security group will also be the same for both EFS and ECS.
Follow the steps to create EFS
From the task definition, create a new revision and enter the required details.
Before creating a container, add EFS related details in Volume.
Volume type: EFS
File system ID: EFS file system ID (It’s shown automatically from dropdown)
Access point ID: If you have an access point ID, please enter.
Root directory: /
Then select ADD.
From the container definition, select Add container. Enter the required details in the Edit container window.
In the STORAGE AND LOGGING section, add the EFS volume name to the mount point and enter the Source Volume path as /application/app_data.
After adding the container, select create. After creating the revision, create a service under the cluster and deploy the Bold Reports application.
Now, app_data is mounted in the EFS storage.
Steps to access the app_data folder in EFS file storage through a Linux VM
Connect any AWS Linux EC2, install the machine, and follow the below command to mount EFS in a folder.
sudo apt-get install nfs-common cd sudo mkdir efs
Go to the EFS console in AWS -> Name -> Attach.
Then copy the NFS client command.
Run the command on the AWS EC2 Linux machine which is copied from the NFS client.
Now, the EFS file is mounted on the Linux machine.