Articles in this section
Category / Section

How to Mount a Persistent Volume for App Data in Amazon AWS ECS Service

Published:
Updated:

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.

Prerequisites

  • 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

  1. From the task definition, create a new revision and enter the required details.

  2. Before creating a container, add EFS related details in Volume.

    Name: any

    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: /

  3. Then select ADD.

    add-volume.png

  4. From the container definition, select Add container. Enter the required details in the Edit container window.

  5. 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.

    storage.png

  6. After adding the container, select create. After creating the revision, create a service under the cluster and deploy the Bold Reports application.

  7. Now, app_data is mounted in the EFS storage.

Steps to access the app_data folder in EFS file storage through a Linux VM

  1. 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
    
  2. Go to the EFS console in AWS -> Name -> Attach.

    EFS-console.png

  3. Then copy the NFS client command.

    client-command.png

  4. Run the command on the AWS EC2 Linux machine which is copied from the NFS client.

  5. Now, the EFS file is mounted on the Linux machine.

    finalefs.png

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied