Created
June 20, 2016 15:17
-
-
Save ryansch/c6782325f19af326cc379450792307f2 to your computer and use it in GitHub Desktop.
Get current AWS region
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def current_region | |
return @current_region if @current_region != nil | |
response = Excon.get( | |
'http://169.254.169.254/latest/meta-data/placement/availability-zone', | |
expects: [200], | |
connect_timeout: 2, | |
read_timeout: 2, | |
write_timeout: 2, | |
tcp_nodelay: true | |
) | |
# chop removes the AZ letter from the end giving us the region | |
@current_region = response.body.chop | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment