Skip to content

Instantly share code, notes, and snippets.

@bongole
Created November 20, 2016 09:30
Show Gist options
  • Save bongole/8734a214636fba22eedcc1fbe32c8023 to your computer and use it in GitHub Desktop.
Save bongole/8734a214636fba22eedcc1fbe32c8023 to your computer and use it in GitHub Desktop.
HOST_IP=$(curl -s 169.254.169.254/latest/meta-data/local-ipv4)
TASKS_JSON=$(curl -s $HOST_IP:51678/v1/tasks)
CONTAINER_ID=$(cat /proc/self/cgroup | grep "cpu:/" | sed 's/.*cpu:\/docker\///g')
TASK_ID=$(echo $TASKS_JSON|jq -r ".Tasks[] | select(.Containers[].DockerId == \"$CONTAINER_ID\") | .Arn"|sed 's/.*task\///')
TASK_FAMILY=$(echo $TASKS_JSON|jq -r ".Tasks[] | select(.Containers[].DockerId == \"$CONTAINER_ID\") | .Family")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment