DEV Community

Yen Trinh
Yen Trinh

Posted on

Mount multiple EFS file system to AWS ECS (Fargate)

For example, you want to mount EFS file system to ECS Fargate as bellow:

Fargate_1: mount EFS_A, EFS_B
Fargate_2: mount EFS_C, EFS_D
Enter fullscreen mode Exit fullscreen mode

Solution:

You can mount EFS file system one by one according to this post:

https://aws.amazon.com/premiumsupport/knowledge-center/ecs-fargate-mount-efs-containers-tasks/

Note that you will have to repeat step 5 to step 12 to mount the second EFS file system

Demo:

Image description

Image description

via JSON:

{
    "ipcMode": null,
    "executionRoleArn": "arn:aws:iam::<account-id>:role/ecsTaskExecutionRole",
    "containerDefinitions": [
        {
            "dnsSearchDomains": null,
            "environmentFiles": null,
            "logConfiguration": {
                "logDriver": "awslogs",
                "secretOptions": null,
                "options": {
                    "awslogs-group": "/ecs/task2",
                    "awslogs-region": "ap-northeast-1",
                    "awslogs-stream-prefix": "ecs"
                }
            },
            "entryPoint": null,
            "portMappings": [],
            "command": null,
            "linuxParameters": null,
            "cpu": 0,
            "environment": [],
            "resourceRequirements": null,
            "ulimits": null,
            "dnsServers": null,
            "mountPoints": [
                {
                    "readOnly": null,
                    "containerPath": "/efs1",
                    "sourceVolume": "efs1"
                },
                {
                    "readOnly": null,
                    "containerPath": "/efs2",
                    "sourceVolume": "efs2"
                }
            ],
            "workingDirectory": null,
            "secrets": null,
            "dockerSecurityOptions": null,
            "memory": null,
            "memoryReservation": null,
            "volumesFrom": [],
            "stopTimeout": null,
            "image": "nginx:latest",
            "startTimeout": null,
            "firelensConfiguration": null,
            "dependsOn": null,
            "disableNetworking": null,
            "interactive": null,
            "healthCheck": null,
            "essential": true,
            "links": null,
            "hostname": null,
            "extraHosts": null,
            "pseudoTerminal": null,
            "user": null,
            "readonlyRootFilesystem": null,
            "dockerLabels": null,
            "systemControls": null,
            "privileged": null,
            "name": "nginx"
        }
    ],
    "memory": "512",
    "taskRoleArn": "arn:aws:iam::<account_id>:role/ecsTaskExecutionRole",
    "family": "task2",
    "pidMode": null,
    "requiresCompatibilities": [
        "FARGATE"
    ],
    "networkMode": "awsvpc",
    "runtimePlatform": {
        "operatingSystemFamily": "LINUX",
        "cpuArchitecture": null
    },
    "cpu": "256",
    "inferenceAccelerators": [],
    "proxyConfiguration": null,
    "volumes": [
        {
            "fsxWindowsFileServerVolumeConfiguration": null,
            "efsVolumeConfiguration": {
                "transitEncryptionPort": null,
                "fileSystemId": "fs-06f7aa4c25718fxxx",
                "authorizationConfig": {
                    "iam": "DISABLED",
                    "accessPointId": null
                },
                "transitEncryption": "DISABLED",
                "rootDirectory": "/"
            },
            "name": "efs1",
            "host": null,
            "dockerVolumeConfiguration": null
        },
        {
            "fsxWindowsFileServerVolumeConfiguration": null,
            "efsVolumeConfiguration": {
                "transitEncryptionPort": null,
                "fileSystemId": "fs-0a04ba637cxxx0e6b",
                "authorizationConfig": {
                    "iam": "DISABLED",
                    "accessPointId": null
                },
                "transitEncryption": "DISABLED",
                "rootDirectory": "/"
            },
            "name": "efs2",
            "host": null,
            "dockerVolumeConfiguration": null
        }
    ],
    "tags": []
}
Enter fullscreen mode Exit fullscreen mode

Result:

Image description

Top comments (0)