Skip to content

Instantly share code, notes, and snippets.

@dreamorosi
Created June 16, 2020 06:50
Show Gist options
  • Save dreamorosi/50cbfd622b478c2433602c16b7321c5d to your computer and use it in GitHub Desktop.
Save dreamorosi/50cbfd622b478c2433602c16b7321c5d to your computer and use it in GitHub Desktop.
Get Instance ID / VM ID on AWS or Azure via bash or powershell command.

Get instance metadata on AWS EC2

curl -H Metadata:true "http://169.254.169.254/latest/meta-data/instance-id"

On Azure Windows VM

curl -H @{'Metadata'='true'} "http://169.254.169.254/metadata/instance/compute/vmId?api-version=2017-08-01&format=text"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment