Skip to content

Commit

Permalink
include fargate type on run task.
Browse files Browse the repository at this point in the history
  • Loading branch information
brunodasilvalenga committed Jun 23, 2021
1 parent 3a26c36 commit 3c86b6e
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 @@ -36,6 +36,13 @@ DB_PASSWORD=
DB_NAME=
```
If the service type is **Fargate**, nad you're using the `run-task.sh` script, please include:
```bash
SERVICE_TYPE=FARGATE
SUBNETS_ID=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" == "FARGARTE" ]]; 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 3c86b6e

Please sign in to comment.