class Aws::Partitions::EndpointProvider

def endpoint_for(region, service, sts_regional_endpoints)

def endpoint_for(region, service, sts_regional_endpoints)
  partition = get_partition(region)
  endpoint = default_endpoint(partition, service, region)
  service_cfg = partition.fetch("services", {}).fetch(service, {})
  # Check for service-level default endpoint.
  endpoint = service_cfg.fetch("defaults", {}).fetch("hostname", endpoint)
  # Check for sts legacy behavior
  sts_legacy = service == 'sts' &&
    sts_regional_endpoints == 'legacy' &&
    STS_LEGACY_REGIONS.include?(region)
  # Check for global endpoint.
  if sts_legacy || service_cfg["isRegionalized"] == false
    region = service_cfg.fetch("partitionEndpoint", region)
  end
  # Can be removed once S3 endpoint is updated
  if (service == 's3') && (region == "us-east-1")
    service_cfg["endpoints"][region] = S3_IAD_REGIONAL
  end
  # Check for service/region level endpoint.
  endpoint = service_cfg.fetch("endpoints", {}).
    fetch(region, {}).fetch("hostname", endpoint)
  endpoint
end