Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I mount an EFS share to AWS Fargate?

I have an AWS EFS share that I store container logs.

I would like to mount this nfs share (aws efs) to AWS Fargate. Is it possible?

Any supporting documentation link would be appreciated.

like image 283
Squirrel Avatar asked Jun 01 '19 01:06

Squirrel


People also ask

Can you mount EFS to fargate?

Be sure that the EFS file system mount target is in the same Availability Zone as the Fargate task. You can view the Availability Zone, subnet, and security group of the mount target in the Amazon EFS console. Then, verify that the mount target uses the same Availability Zone and subnet as the Fargate task.

Does AWS fargate support EFS?

To mount an Amazon EFS file system on a Fargate task or container, you must create a task definition, and then make that task definition available to the containers in your task across all Availability Zones in your AWS Region.

Can EFS be mounted on premise?

You can mount your Amazon EFS file systems on your on-premises data center servers when connected to your Amazon VPC with AWS Direct Connect or VPN.


2 Answers

You can do this since April 2020! It's a little tricky but works.

The biggest gotcha I ran into was that you need to set the "Platform version" to 1.4.0 - it will default to "Latest" which is 1.3.0.

In your Container Definitions you need to define a volume and a mountpoint where you want the EFS share mounted inside the container:

Volume:

     "volumes": [
        {
          "efsVolumeConfiguration": {
            "transitEncryptionPort": null,
            "fileSystemId": "fs-xxxxxxx",
            "authorizationConfig": {
              "iam": "DISABLED",
              "accessPointId": "fsap-xxxxxxxx"
            },
            "transitEncryption": "ENABLED",
            "rootDirectory": "/"
          },
          "name": "efs volume name",
          "host": null,
          "dockerVolumeConfiguration": null
        }
      ]

Mount volume in container:

 "mountPoints": [
         {
          "readOnly": null,
          "containerPath": "/opt/your-app",
          "sourceVolume": "efs volume name"
          }

These posts helped me although they're missing a few details:

Tutorial: Using Amazon EFS file systems with Amazon ECS

EFSVolumeConfiguration

like image 101
TheFiddlerWins Avatar answered Oct 19 '22 16:10

TheFiddlerWins


EFS support for Fargate is now available!

https://aws.amazon.com/about-aws/whats-new/2020/04/amazon-ecs-aws-fargate-support-amazon-efs-filesystems-generally-available/

like image 21
NIrav Modi Avatar answered Oct 19 '22 17:10

NIrav Modi