From 79687f17572c3c0e9b876e6c37feebfed3f0042e Mon Sep 17 00:00:00 2001 From: hideto0710 Date: Thu, 16 Nov 2017 01:28:50 +0900 Subject: [PATCH] check_existence_of_region --- lib/fog/aws/credential_fetcher.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/fog/aws/credential_fetcher.rb b/lib/fog/aws/credential_fetcher.rb index 05dc2f705..c355ce371 100644 --- a/lib/fog/aws/credential_fetcher.rb +++ b/lib/fog/aws/credential_fetcher.rb @@ -23,8 +23,10 @@ module Fog credential_path = options[:credential_path] || ENV["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"] role_data = connection.get(:path => credential_path, :idempotent => true, :expects => 200).body - connection = options[:metadata_connection] || Excon.new(INSTANCE_METADATA_HOST) - region ||= connection.get(:path => INSTANCE_METADATA_AZ, :idempotent => true, :expects => 200).body[0..-2] + if region.nil? + connection = options[:metadata_connection] || Excon.new(INSTANCE_METADATA_HOST) + region = connection.get(:path => INSTANCE_METADATA_AZ, :idempotent => true, :expects => 200).body[0..-2] + end else connection = options[:connection] || Excon.new(INSTANCE_METADATA_HOST) role_name = connection.get(:path => INSTANCE_METADATA_PATH, :idempotent => true, :expects => 200).body