Skip to content

Commit 61d6b9d

Browse files
Include service type fargate on run-task.sh
1 parent 76cca18 commit 61d6b9d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ DB_PASSWORD=
4343
DB_NAME=
4444
```
4545
46+
If the service type is **Fargate**, and you're using the `run-task.sh` script, please include:
47+
```bash
48+
SERVICE_TYPE=FARGATE
49+
SUBNETS=subnet1231231,subnet123123123,subnter123123123123
50+
```
51+
Default values are: null
52+
4653
`task-definition.tpl.json` (example)
4754
```json
4855
{

src/run-task.sh

+12
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" == "FARGATE" ]]; 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)