Is there a way to look up the region of an instance from within the instance?
I\'m looking for something similar to the method of finding the instance id.
A method using only egrep, which should work on most any linux instance spun up without having to install any extra tooling. I tested this against a list of all current AWS regions and they all match.
curl http://169.254.169.254/latest/meta-data/placement/availability-zone | egrep -o '(\w)+-(\w)+-[0-9]'
region=$(curl http://169.254.169.254/latest/meta-data/placement/availability-zone | egrep -o '(\w)+-(\w)+-[0-9]')