Skip to content

Commit 3c86b6e

Browse files
include fargate type on run task.
1 parent 3a26c36 commit 3c86b6e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ DB_PASSWORD=
3636
DB_NAME=
3737
```
3838
39+
If the service type is **Fargate**, nad you're using the `run-task.sh` script, please include:
40+
```bash
41+
SERVICE_TYPE=FARGATE
42+
SUBNETS_ID=subnet1231231,subnet123123123,subnter123123123123
43+
```
44+
Default values are: null
45+
3946
`task-definition.tpl.json` (example)
4047
```json
4148
{

src/run-task.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,23 @@ echo " CLUSTER_NAME: ${CLUSTER_NAME}"
3131
echo " APP_NAME: ${APP_NAME}"
3232
echo " TASK_DEFINITION_ARN: ${TASK_ARN}"
3333
echo -n " STATUS: "
34+
35+
# Check if cluster type is fargate
36+
if [[ "$SERVICE_TYPE" == "FARGARTE" ]]; then
37+
TASK_ID=$(aws ecs run-task \
38+
--cluster $CLUSTER_NAME \
39+
--task-definition $TASK_ARN \
40+
--network-configuration "awsvpcConfiguration={subnets=[${SUBNETS}]" \
41+
--launch-type FARGATE \
42+
--query="tasks[0].taskArn" \
43+
--output=text)
44+
else
3445
TASK_ID=$(aws ecs run-task \
3546
--cluster $CLUSTER_NAME \
3647
--task-definition $TASK_ARN \
3748
--query="tasks[0].taskArn" \
3849
--output=text)
50+
fi
3951

4052
sleep 5
4153

0 commit comments

Comments
 (0)