class Aws::InstanceProfileCredentials

def _get_credentials(conn, token)

token is optional - if nil, uses v1 (insecure) flow
def _get_credentials(conn, token)
  metadata = http_get(conn, METADATA_PATH_BASE, token)
  profile_name = metadata.lines.first.strip
  http_get(conn, METADATA_PATH_BASE + profile_name, token)
rescue TokenExpiredError
  # Token has expired, reset it
  # The next retry should fetch it
  @token = nil
  @imds_v1_fallback = false
  raise Non200Response
end