EC2 Task EFS mount issue

0

Hi, I have a task in a cluster of one EC2 node, and an EFS. In the task, I have defined the volume and mounted it to a location on EC2. From the logs I can see that it gets mounted however I dont see it with df -T or df -h. I am also able to mount it manually with sudo mount -t efs, which means that there is no connection issues between my ec2 and EFS. Thanks.

Here is the logs: ecs-volume-plugin.log:level=info time=2021-12-04T20:11:58Z msg="Returning volume information for ecs-core-14-test-efs-test-86ded2bd90b585eb7f00" ecs-volume-plugin.log:level=info time=2021-12-04T20:41:49Z msg="Returning volume information for ecs-core-14-test-efs-test-86ded2bd90b585eb7f00" ecs-volume-plugin.log:level=info time=2021-12-04T20:41:49Z msg="Returning volume information for ecs-core-14-test-efs-test-86ded2bd90b585eb7f00" ecs-volume-plugin.log:level=info time=2021-12-04T20:41:49Z msg="Returning volume information for ecs-core-14-test-efs-test-86ded2bd90b585eb7f00" ecs-volume-plugin.log:level=info time=2021-12-04T20:41:54Z msg="Creating new volume ecs-core-14-test-efs-test-d4acb6f880d4faba5400" ecs-volume-plugin.log:level=info time=2021-12-04T20:41:54Z msg="Creating mount target for new volume ecs-core-14-test-efs-test-d4acb6f880d4faba5400" ecs-volume-plugin.log:level=info time=2021-12-04T20:41:54Z msg="Validating create options for volume ecs-core-14-test-efs-test-d4acb6f880d4faba5400" ecs-volume-plugin.log:level=info time=2021-12-04T20:41:54Z msg="Mounting volume ecs-core-14-test-efs-test-d4acb6f880d4faba5400 of type efs at path /var/lib/ecs/volume s/ecs-core-14-test-efs-test-d4acb6f880d4faba5400" ecs-volume-plugin.log:level=info time=2021-12-04T20:41:54Z msg="Volume ecs-core-14-test-efs-test-d4acb6f880d4faba5400 created successfully" ecs-volume-plugin.log:level=info time=2021-12-04T20:41:54Z msg="Saving state of new volume ecs-core-14-test-efs-test-d4acb6f880d4faba5400" ecs-volume-plugin.log:level=info time=2021-12-04T20:41:55Z msg="Returning volume information for ecs-core-14-test-efs-test-d4acb6f880d4faba5400" ecs-volume-plugin.log:level=info time=2021-12-04T20:41:56Z msg="Returning volume information for ecs-core-14-test-efs-test-d4acb6f880d4faba5400"

2 Answers
1

You do not need to mount the file system on the EC2 instance to be able to (bind?) mount it in the task. ECS is able to mount the EFS volume inside the task directly (without configuring the EC2 instance). We use this mechanism to mount the volume into a Fargate task as well (with Fargate you don't get access to the instance). It's unclear where you are running the df command but if you can ECS exec into the container you should be able to verify the volume has been mounted in the folder you specified in the task def. This blog should provide more details.

AWS
EXPERT
answered 2 years ago
  • I do want to mount it via the task. I mentioned I mounted manually myself to make sure that the security groups used between efs and ec2 instances are set correctly and the NFS inbound rule to efs works fine. I did df on the EC2 instance to see if the task has done the mounting or not.

  • I think there is a problem with one of the roles, either the role assigned to the task or the role used for when create the cluster, as that rule is the one that EC2 uses or inherits as well. which one is involved in the mounting process, the one defined in the task or the one define in cluster? also tasks have two: task role and task execution role...I guess my docker image uses task role, and the task execution role is the one used for fetching images from gitlab and accessing Secrets manager. but is it involved in mounting efs too?

  • The role you need to have EFS permissions for is the IAM role (not the IAM execution role). You can refer to this blog/tutorial

1

Hi - here are the steps to mount EFS using an ECS task, so check that you have completed every step - https://docs.aws.amazon.com/AmazonECS/latest/developerguide/tutorial-efs-volumes.html.

I would look at the userdata section and ensure the mount is specified with the correct mount options for EFS (you can see these in the EFS console) and also check the userdata script logs ( /var/log/user-data.log ) to make sure there are no subsequent errors.

AWS
Oli
answered 2 years ago
  • Thanks for the reply. I dont have a user-data.log file in /var/log or /var/log/ecs. What I have under /var/log/ecs is: ecs-agent.log, audit.log and ecs-volume-plugin.log. I am wondering where the log for actual mounting is... Thanks.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions