Sha256: e35c9718c0715fb7bb64d68fa57302be19eaa93410f6c6922c1c53ce413c9884
Contents?: true
Size: 992 Bytes
Versions: 25
Compression:
Stored size: 992 Bytes
Contents
module Jets class AwsInfo extend Memoist include AwsServices def region return 'us-east-1' if test? region = nil # First try to get it from the ~/.aws/config region = `aws configure get region`.strip rescue nil return region if region # Second try the metadata endpoint, should be available on AWS Lambda environment # https://stackoverflow.com/questions/4249488/find-region-from-within-an-ec2-instance begin az = `curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone` region = az.strip.chop # remove last char rescue end return region if region ENV['JETS_AWS_REGION'] || 'us-east-1' # default if all else fails end memoize :region # aws sts get-caller-identity def account return '123456789' if test? sts.get_caller_identity.account end memoize :account def test? ENV['TEST'] || ENV['CIRCLECI'] end end end
Version data entries
25 entries across 25 versions & 1 rubygems