Differences between revisions 1 and 2
Revision 1 as of 2022-05-01 21:12:03
Size: 974
Editor: PieterSmit
Comment:
Revision 2 as of 2022-05-01 21:37:48
Size: 1170
Editor: PieterSmit
Comment:
Deletions are marked like this. Additions are marked like this.
Line 17: Line 17:
 * Use TOKEN to get tags {{{  * Use TOKEN to get tags (Tags not available by default, have to enable see [[https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#work-with-tags-in-IMDS|--metadata-options "InstanceMetadataTags=enabled"]] {{{

AWS/Ec2MetaData

  • https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html

  • Get TOKEN env var and then list of endpoints

    TOKEN=`curl -sS -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
    echo "TOKEN=$TOKEN"
    curl -H "X-aws-ec2-metadata-token: $TOKEN" -v http://169.254.169.254/latest/meta-data/
  • Use TOKEN env to get hostname

    # for debug replace -sS with -v
    curl -H "X-aws-ec2-metadata-token: $TOKEN" -sS http://169.254.169.254/latest/meta-data/local-hostname ; echo
    curl -H "X-aws-ec2-metadata-token: $TOKEN" -sS http://169.254.169.254/latest/meta-data/public-hostname ; echo
  • Use TOKEN to get tags (Tags not available by default, have to enable see --metadata-options "InstanceMetadataTags=enabled"

    TOKEN=`curl -sS -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
    echo "TOKEN=$TOKEN"
    curl -H "X-aws-ec2-metadata-token: $TOKEN" -sS http://169.254.169.254/latest/meta-data/tags/instance

AWS/Ec2MetaData (last edited 2022-05-01 21:59:56 by PieterSmit)