From 95f689aae5a1b5784a38cf63cfda826828443e11 Mon Sep 17 00:00:00 2001 From: kakakakakku Date: Thu, 14 Dec 2017 16:11:47 +0900 Subject: [PATCH 1/2] Supported AWS Fargate --- ecs-deploy | 7 ++++++ test.bats | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/ecs-deploy b/ecs-deploy index a935127..7124a62 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -275,6 +275,13 @@ function createNewTaskDefJson() { fi done + # Updated jq filters for AWS Fargate + REQUIRES_COMPATIBILITIES=$(echo "${DEF}" | jq -r '. | select(.requiresCompatibilities != null) | .requiresCompatibilities[]') + if [[ "${REQUIRES_COMPATIBILITIES}" == 'FARGATE' ]]; then + FARGATE_JQ_FILTER='executionRoleArn: .executionRoleArn, requiresCompatibilities: .requiresCompatibilities, cpu: .cpu, memory: .memory' + NEW_DEF_JQ_FILTER="${NEW_DEF_JQ_FILTER}, ${FARGATE_JQ_FILTER}" + fi + # Build new DEF with jq filter NEW_DEF=$(echo $DEF | jq "{${NEW_DEF_JQ_FILTER}}") diff --git a/test.bats b/test.bats index 9262d0a..1566632 100755 --- a/test.bats +++ b/test.bats @@ -281,6 +281,72 @@ EOF [ $output == $expected ] } +@test "test createNewTaskDefJson with single container in definition for AWS Fargate" { + imageWithoutTag="121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo" + useImage="121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo:1111111111" + TASK_DEFINITION=$(cat < Date: Sat, 31 Mar 2018 13:08:39 +0900 Subject: [PATCH 2/2] Supported placementConstraints for tests --- test.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.bats b/test.bats index 1566632..281b3aa 100755 --- a/test.bats +++ b/test.bats @@ -341,7 +341,7 @@ EOF } EOF ) - expected='{ "family": "app-task-def", "volumes": [], "containerDefinitions": [ { "environment": [ { "name": "KEY", "value": "value" } ], "name": "API", "links": [], "mountPoints": [], "image": "121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo:1111111111", "essential": true, "portMappings": [ { "protocol": "tcp", "containerPort": 80, "hostPort": 10080 } ], "entryPoint": [], "memory": 128, "command": [ "/data/run.sh" ], "cpu": 200, "volumesFrom": [] } ], "networkMode": "awsvpc", "executionRoleArn": "arn:aws:iam::121212345678:role/ecsTaskExecutionRole", "requiresCompatibilities": [ "FARGATE" ], "cpu": "256", "memory": "512" }' + expected='{ "family": "app-task-def", "volumes": [], "containerDefinitions": [ { "environment": [ { "name": "KEY", "value": "value" } ], "name": "API", "links": [], "mountPoints": [], "image": "121212345678.dkr.ecr.us-east-1.amazonaws.com/acct/repo:1111111111", "essential": true, "portMappings": [ { "protocol": "tcp", "containerPort": 80, "hostPort": 10080 } ], "entryPoint": [], "memory": 128, "command": [ "/data/run.sh" ], "cpu": 200, "volumesFrom": [] } ], "placementConstraints": null, "networkMode": "awsvpc", "executionRoleArn": "arn:aws:iam::121212345678:role/ecsTaskExecutionRole", "requiresCompatibilities": [ "FARGATE" ], "cpu": "256", "memory": "512" }' run createNewTaskDefJson [ ! -z $status ] [ $output == $expected ]