diff --git a/ecs-deploy b/ecs-deploy index 637e793..1e94c6c 100755 --- a/ecs-deploy +++ b/ecs-deploy @@ -273,6 +273,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 bd210c5..baab06a 100755 --- a/test.bats +++ b/test.bats @@ -280,6 +280,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 <