Skip to content

Instantly share code, notes, and snippets.

@pcolazurdo
Created November 13, 2019 13:14
Show Gist options
  • Save pcolazurdo/a17bf6a065c1384a06fc14d2499eb48f to your computer and use it in GitHub Desktop.
Save pcolazurdo/a17bf6a065c1384a06fc14d2499eb48f to your computer and use it in GitHub Desktop.
Set AWS REGION from Metadata Service
#!/bin/bash
export AWS_AVAILABILITY_ZONE=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone)
export AWS_REGION=${AWS_AVAILABILITY_ZONE%?}
# From http://tldp.org/LDP/abs/html/string-manipulation.html :
# ${string%substring}
# Deletes shortest match of $substring from back of $string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment