Skip to content

Instantly share code, notes, and snippets.

@gchait
Created December 13, 2025 12:14
Show Gist options
  • Select an option

  • Save gchait/3884f838c500f8c2f7963ea93405fdd2 to your computer and use it in GitHub Desktop.

Select an option

Save gchait/3884f838c500f8c2f7963ea93405fdd2 to your computer and use it in GitHub Desktop.
Treat an ECS task as a job
# shellcheck disable=SC2086
set -o allexport
source .env
set +o allexport
cluster_args="--cluster ${ECS_CLUSTER} --region ${REGION}"
net_config="{\"awsvpcConfiguration\":{\"assignPublicIp\":\"XXX\",\"subnets\":[\"${SUBNET_ID}\"]}}"
task_arn=$(aws ecs run-task ${cluster_args} \
--task-definition "${ECS_TASK_DEF_ARN}" --launch-type FARGATE \
--network-configuration "${net_config}" \
--query 'tasks[].taskArn')
aws ecs wait tasks-running ${cluster_args} --tasks "${task_arn}"
aws ecs wait tasks-stopped ${cluster_args} --tasks "${task_arn}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment