Skip to content

Instantly share code, notes, and snippets.

@9bo9bo
Last active July 19, 2021 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 9bo9bo/dd7ea4a58b92749b6d4a10662331de69 to your computer and use it in GitHub Desktop.
Save 9bo9bo/dd7ea4a58b92749b6d4a10662331de69 to your computer and use it in GitHub Desktop.
ECS/Fargate環境で実行中のコンテナ内で自身のタスクIDを取得する
export CONTAINER_TASK_ID=$(curl -s ${ECS_CONTAINER_METADATA_URI}/task | jq -r '.TaskARN | split("/") | .[2]')
export CONTAINER_TASK_ID=$(php -r '$meta=json_decode(file_get_contents("{$_ENV["ECS_CONTAINER_METADATA_URI"]}/task"),true);$taskId=explode("/",$meta["TaskARN"])[2];print($taskId);')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment