Skip to content

Commit

Permalink
Include service type fargate on run-task.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
brunodasilvalenga committed Jun 23, 2021
1 parent 76cca18 commit 61d6b9d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ DB_PASSWORD=
DB_NAME=
```
If the service type is **Fargate**, and you're using the `run-task.sh` script, please include:
```bash
SERVICE_TYPE=FARGATE
SUBNETS=subnet1231231,subnet123123123,subnter123123123123
```
Default values are: null

`task-definition.tpl.json` (example)
```json
{
Expand Down
12 changes: 12 additions & 0 deletions src/run-task.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,23 @@ echo " CLUSTER_NAME: ${CLUSTER_NAME}"
echo " APP_NAME: ${APP_NAME}"
echo " TASK_DEFINITION_ARN: ${TASK_ARN}"
echo -n " STATUS: "

# Check if cluster type is fargate
if [[ "$SERVICE_TYPE" == "FARGATE" ]]; then
TASK_ID=$(aws ecs run-task \
--cluster $CLUSTER_NAME \
--task-definition $TASK_ARN \
--network-configuration "awsvpcConfiguration={subnets=[${SUBNETS}]}" \
--launch-type FARGATE \
--query="tasks[0].taskArn" \
--output=text)
else
TASK_ID=$(aws ecs run-task \
--cluster $CLUSTER_NAME \
--task-definition $TASK_ARN \
--query="tasks[0].taskArn" \
--output=text)
fi

sleep 5

Expand Down

0 comments on commit 61d6b9d

Please sign in to comment.