class Aws::InstanceProfileCredentials

def resolve_endpoint(options, endpoint_mode)

def resolve_endpoint(options, endpoint_mode)
  value = options[:endpoint] || options[:ip_address]
  value ||= ENV['AWS_EC2_METADATA_SERVICE_ENDPOINT']
  value ||= Aws.shared_config.ec2_metadata_service_endpoint(
    profile: options[:profile]
  )
  return value if value
  case endpoint_mode.downcase
  when 'ipv4' then 'http://169.254.169.254'
  when 'ipv6' then 'http://[fd00:ec2::254]'
  else
    raise ArgumentError,
          ':endpoint_mode is not valid, expected IPv4 or IPv6, '\
          "got: #{endpoint_mode}"
  end
end