[ECS] [Fargate] Script to get Task ID in TASK execution container

There wasn't a very good way to look it up, so I made it for the time being.

TD;DR

#!/bin/bash

METADATA=$(curl ${ECS_CONTAINER_METADATA_URI}/task)
python3 -c "import json; meta=json.loads('$METADATA'); task_id=meta['TaskARN'].split('/')[-1]; print(task_id)" > ./task_id
TASK_ID=$(cat ./task_id)

I want to get a TASK ID

Summary

reference

Recommended Posts

[ECS] [Fargate] Script to get Task ID in TASK execution container
How to get results from id in Celery
I wrote a script to get a popular site in Japan
Get the script path in Python
Pass arguments to Task in discord.py
How to get parent id with sqlalchemy
Pin current directory to script directory in Python
Sample script to trap signals in Python
How to get a stacktrace in python
Parallel task execution using concurrent.futures in Python
I want to set a life cycle in the task definition of ECS