Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michalstala/49b33210cb841f6fdf8d5d08db20e94c to your computer and use it in GitHub Desktop.
Save michalstala/49b33210cb841f6fdf8d5d08db20e94c to your computer and use it in GitHub Desktop.
How to retrieve EC2 region information from instance metadata

Query the instance metadata using curl and parse the output with jq tool

curl --silent http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region

Example Output:

us-east-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment