eddmann / serverless-fargate

Maintain long-running Fargate ECS tasks within your Serverless project
53 stars 22 forks source link

Support for multiple images in single task definition #50

Closed vedika9009 closed 4 months ago

vedika9009 commented 11 months ago

Right now I can specify only one image for a task definition. However for sidecar pattern and some other use cases i need multiple images within the same task definition.

Also support for portmappings is needed

example task definiton { "taskDefinitionArn": "arn:aws:ecs:eu-central-1:xxxxxxx:task-definition/sel-hub:8", "containerDefinitions": [ { "name": "sel-hub", "image": "xxxx.dkr.ecr.eu-central-1.amazonaws.com/serverless-balance-dev@sha256:c314c89c7b7b883223b7355441bb308d150848941419b4768ab0301d7e135d5d", "cpu": 0, "links": [], "portMappings": [ { "name": "sel-hub-4444-tcp", "containerPort": 4444, "hostPort": 4444, "protocol": "tcp", "appProtocol": "http" } ], "essential": true, "environment": [ { "name": "VNC_NO_PASSWORD", "value": "1" } ], "environmentFiles": [], "mountPoints": [ { "sourceVolume": "my_mount", "containerPath": "/mymount", "readOnly": false } ], "volumesFrom": [], "dockerSecurityOptions": [], "ulimits": [], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-group": "balance-dev-FargateTasksLogGroup-j6xFz6EuUtyM", "awslogs-region": "eu-central-1", "awslogs-stream-prefix": "fargate" }, "secretOptions": [] }, "healthCheck": { "command": [ "CMD-SHELL", "curl -f http://localhost:4444/ || exit 1" ], "interval": 30, "timeout": 5, "retries": 3, "startPeriod": 20 }, "systemControls": [] }, { "name": "python39", "image": "xxxxx.dkr.ecr.eu-central-1.amazonaws.com/serverless-balance-dev:python39", "cpu": 0, "portMappings": [], "essential": true, "environment": [], "environmentFiles": [], "mountPoints": [ { "sourceVolume": "my_mount", "containerPath": "/mymount", "readOnly": false } ], "volumesFrom": [], "dependsOn": [ { "containerName": "sel-hub", "condition": "HEALTHY" } ], "logConfiguration": { "logDriver": "awslogs", "options": { "awslogs-create-group": "true", "awslogs-group": "/ecs/sel-hub", "awslogs-region": "eu-central-1", "awslogs-stream-prefix": "ecs" }, "secretOptions": [] } } ], "family": "sel-hub", "taskRoleArn": "arn:aws:iam::xxxxx:role/dev-balance-iam-role", "executionRoleArn": "arn:aws:iam::xxxxxx:role/dev-balance-iam-role", "networkMode": "awsvpc", "revision": 8, "volumes": [ { "name": "my_mount", "host": {} } ], "status": "ACTIVE", "requiresAttributes": [ { "name": "com.amazonaws.ecs.capability.logging-driver.awslogs" }, { "name": "ecs.capability.execution-role-awslogs" }, { "name": "com.amazonaws.ecs.capability.ecr-auth" }, { "name": "com.amazonaws.ecs.capability.docker-remote-api.1.19" }, { "name": "com.amazonaws.ecs.capability.docker-remote-api.1.21" }, { "name": "com.amazonaws.ecs.capability.task-iam-role" }, { "name": "ecs.capability.container-health-check" }, { "name": "ecs.capability.container-ordering" }, { "name": "ecs.capability.execution-role-ecr-pull" }, { "name": "com.amazonaws.ecs.capability.docker-remote-api.1.18" }, { "name": "ecs.capability.task-eni" }, { "name": "com.amazonaws.ecs.capability.docker-remote-api.1.29" } ], "placementConstraints": [], "compatibilities": [ "EC2", "FARGATE" ], "requiresCompatibilities": [ "FARGATE" ], "cpu": "256", "memory": "512", "registeredAt": "2023-12-04T02:36:52.318Z", "tags": [ { "key": "STAGE", "value": "dev" } ] }

eddmann commented 4 months ago

You should be able to achieve this using the cloudFormationResource extension property. An example can be found in the README