Last active
July 19, 2021 13:23
-
-
Save 9bo9bo/dd7ea4a58b92749b6d4a10662331de69 to your computer and use it in GitHub Desktop.
ECS/Fargate環境で実行中のコンテナ内で自身のタスクIDを取得する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export CONTAINER_TASK_ID=$(curl -s ${ECS_CONTAINER_METADATA_URI}/task | jq -r '.TaskARN | split("/") | .[2]') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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