I have an EFS that I want to mount it to an ECS cluster (running on EC2 instances).
My cluster is running multiple apps and I want that each app use a sub folder of the EFS.
During the launch config of the EC2 I create the different folders for apps under /mnt/efs
Then I tried in the Task Definition to put the subfolder in the EFS URL this way:
resource "aws_ecs_task_definition" "task_definition" {
...
volume {
name = "efs_app1"
docker_volume_configuration {
scope = "shared"
autoprovision = true
driver = "local"
driver_opts = {
"type" = "nfs"
"device" = "${aws_efs_file_system.efs.dns_name}:/"
"o" = "addr=${aws_efs_file_system.efs.dns_name}:/app1,nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2"
}
}
}
But the container is unable to start and generates this error:
Status reason CannotCreateContainerError: Error response from daemon: error resolving passed in nfs address: lookup fs-xxxxxxx.efs.eu-west-1.amazonaws.com:/app1: no such host
I'm not sure of the syntax that I used to specify the sub folder when mounting the volume. Is it correct? Or is there any way to fix that?