amazon-ecs-cli icon indicating copy to clipboard operation
amazon-ecs-cli copied to clipboard

ecs-cli local not working with efs volumes

Open NigelSwinson opened this issue 4 years ago • 3 comments

Summary

I have an ECS task which uses EFS. This works fine "in prod" but doesn't work in local mode. When I try to run in local mode I get this error: "invalid mount config for type "bind": field Source must not be empty"

Description

With ecs-cli 1.20.0 (7547c45), I run: ecs-cli local up --task-def-remote web-dev

Where the web-dev task has:

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

And:

      "mountPoints": [
        {
          "readOnly": null,
          "containerPath": "/efs/recordings",
          "sourceVolume": "efs-recordings"
        }
      ],

The resulting docker-compose.cs-local.yml has:

    volumes:
    - type: bind
      target: /efs/recordings

As indicated, there's no "source" parameter in there, so docker bails on the command. When I run the same code direct on ecs, it works fine, I can access the efs file system. I can also mount the efs file system on the EC2 host on which I'm running ecs-cli. Looking at https://github.com/aws/amazon-ecs-cli/pull/1019 it looks like the efs volume should not have type:bind, rather should look something like:

    volumes:
      - efs-recordings:/efs/recordings

But then as per https://github.com/aws/amazon-ecs-cli/pull/1019, the ecs-params.yml should have an efs_volumes section which details what efs-recordings means. So I create an ecs-params.yml:

version: 1
task_definition:
  efs_volumes:
    - name: "efs-recordings"
      filesystem_id: "fs-########"
      root_directory: /
      transit_encryption: ENABLED
      iam: ENABLED

But this makes no difference; it's not clear to me that ecs-cli will go anywhere near ecs-params.yml when run in local mode.

Is efs not supported in local mode? Could the error messages be more helpful?

NigelSwinson avatar Aug 19 '20 22:08 NigelSwinson

Note to unblock myself; I mounted the EFS file system in the EC2 host (installing the EFS Mount Helper) using the desired access point, then changed my ECS task definition to specify the Volume should be of type "Bind Mount". e.g.

    volumes:
    - type: bind
      source: /efs/recordings
      target: /efs/recordings

I now have access to the efs file system in both the EC2 host, and inside the docker container, started using ecs-cli local.

Assuming ecs-cli local doesn't support EFS; I recommend, for the sake of those who come after me (Customer Obsession); that ecs-cli local should at least provide an error message advising that this ECS task configuration isn't supported in local mode, and then point at some AWS documentation. Or ideally support EFS volumes in local mode.

P.S. While I'm here, I'm puzzled why ecs-cli local is not listed here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cmd-ecs-cli.html But is listed here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_CLI_reference.html

NigelSwinson avatar Aug 20 '20 00:08 NigelSwinson

@NigelSwinson thank you for reporting! This does appear to be gap in documentation & in-app messaging that we should improve. Same goes for the ecs-cli command page gap you identified. The user guide does have a dedicated ecs-cli local page which can be linked to here.

allisaurus avatar Aug 26 '20 15:08 allisaurus

Still no support for EFS mounts using ecs-cli local ?

ryaudio avatar May 30 '23 18:05 ryaudio