Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Multiple Volumes in ECS Compose pointing to same EFS Filesystem #2243

Open
@Rfferrao87

Description

@Rfferrao87

I would like to propose the possibility of creating a single MountTarget for multiple Access Points in ECS compose. I am quite new to AWS and not sure if it would be a good practice, however I do not like having to create multiple EFS Filesystems to accomodate every volume defined in my compose file.

For example, I have the following compose file:

version: '3.7'

services:
  ftp-server:
    container_name: my-ftp-server
    environment:
      - FTP_PASS=123
      - FTP_USER=user
    image: garethflowers/ftp-server
    ports:
      - '20-21:20-21/tcp'
      - '40000-40002:40000-40002/tcp'
    volumes:
      - 'config-dir:/home/user/config'
      - 'data-dir:/home/user/data'

volumes:
  config-dir:
    external: true
    name: fs-0211e5a42036764bd
  data-dir:
    external: true
    name: fs-0211e5a42036764bd

Problem is, when I convert it to the Cloudformation template, it tries to create 2 Mount Targets for each volume, with the same subnet, in the same Filesystem. Example below:

AWSTemplateFormatVersion: 2010-09-09
Resources:
...
  ConfigdirAccessPoint:
    Properties:
      AccessPointTags:
      - Key: com.docker.compose.project
        Value: docker-ftp-server
      - Key: com.docker.compose.volume
        Value: config-dir
      - Key: Name
        Value: fs-0211e5a42036764bd
      FileSystemId: fs-0211e5a42036764bd
    Type: AWS::EFS::AccessPoint
  ConfigdirNFSMountTargetOnSubnet06d4cbe3216168915:
    Properties:
      FileSystemId: fs-0211e5a42036764bd
      SecurityGroups:
      - Ref: DefaultNetwork
      SubnetId: subnet-06d4cbe3216168915
    Type: AWS::EFS::MountTarget
  ConfigdirNFSMountTargetOnSubnet007a8c32c41574882:
    Properties:
      FileSystemId: fs-0211e5a42036764bd
      SecurityGroups:
      - Ref: DefaultNetwork
      SubnetId: subnet-007a8c32c41574882
    Type: AWS::EFS::MountTarget
  ConfigdirNFSMountTargetOnSubnet019c921272db60f58:
    Properties:
      FileSystemId: fs-0211e5a42036764bd
      SecurityGroups:
      - Ref: DefaultNetwork
      SubnetId: subnet-019c921272db60f58
    Type: AWS::EFS::MountTarget
  ConfigdirNFSMountTargetOnSubnet045795de25fae67b0:
    Properties:
      FileSystemId: fs-0211e5a42036764bd
      SecurityGroups:
      - Ref: DefaultNetwork
      SubnetId: subnet-045795de25fae67b0
    Type: AWS::EFS::MountTarget
  ConfigdirNFSMountTargetOnSubnet0a1e195edb8c3e37d:
    Properties:
      FileSystemId: fs-0211e5a42036764bd
      SecurityGroups:
      - Ref: DefaultNetwork
      SubnetId: subnet-0a1e195edb8c3e37d
    Type: AWS::EFS::MountTarget
  ConfigdirNFSMountTargetOnSubnet0b9991c2f7782cadb:
    Properties:
      FileSystemId: fs-0211e5a42036764bd
      SecurityGroups:
      - Ref: DefaultNetwork
      SubnetId: subnet-0b9991c2f7782cadb
    Type: AWS::EFS::MountTarget
  DatadirAccessPoint:
    Properties:
      AccessPointTags:
      - Key: com.docker.compose.project
        Value: docker-ftp-server
      - Key: com.docker.compose.volume
        Value: data-dir
      - Key: Name
        Value: fs-0211e5a42036764bd
      FileSystemId: fs-0211e5a42036764bd
    Type: AWS::EFS::AccessPoint
  DatadirNFSMountTargetOnSubnet06d4cbe3216168915:
    Properties:
      FileSystemId: fs-0211e5a42036764bd
      SecurityGroups:
      - Ref: DefaultNetwork
      SubnetId: subnet-06d4cbe3216168915
    Type: AWS::EFS::MountTarget
  DatadirNFSMountTargetOnSubnet007a8c32c41574882:
    Properties:
      FileSystemId: fs-0211e5a42036764bd
      SecurityGroups:
      - Ref: DefaultNetwork
      SubnetId: subnet-007a8c32c41574882
    Type: AWS::EFS::MountTarget
  DatadirNFSMountTargetOnSubnet019c921272db60f58:
    Properties:
      FileSystemId: fs-0211e5a42036764bd
      SecurityGroups:
      - Ref: DefaultNetwork
      SubnetId: subnet-019c921272db60f58
    Type: AWS::EFS::MountTarget
  DatadirNFSMountTargetOnSubnet045795de25fae67b0:
    Properties:
      FileSystemId: fs-0211e5a42036764bd
      SecurityGroups:
      - Ref: DefaultNetwork
      SubnetId: subnet-045795de25fae67b0
    Type: AWS::EFS::MountTarget
  DatadirNFSMountTargetOnSubnet0a1e195edb8c3e37d:
    Properties:
      FileSystemId: fs-0211e5a42036764bd
      SecurityGroups:
      - Ref: DefaultNetwork
      SubnetId: subnet-0a1e195edb8c3e37d
    Type: AWS::EFS::MountTarget
  DatadirNFSMountTargetOnSubnet0b9991c2f7782cadb:
    Properties:
      FileSystemId: fs-0211e5a42036764bd
      SecurityGroups:
      - Ref: DefaultNetwork
      SubnetId: subnet-0b9991c2f7782cadb
    Type: AWS::EFS::MountTarget

The example above fails because of the aforementioned situation, so would it be pertinent to force multiple volumes, that are pointing to the same Filesystem ID, use the same Mount Targets when running ECS Compose?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions