lib/aws-partitions/endpoint_provider.rb in aws-partitions-1.431.0 vs lib/aws-partitions/endpoint_provider.rb in aws-partitions-1.431.1
- old
+ new
@@ -64,27 +64,32 @@
def endpoint_for(region, service, sts_regional_endpoints)
partition = get_partition(region)
service_cfg = partition.fetch('services', {}).fetch(service, {})
# Find the default endpoint
- endpoint = service_cfg
+ default_endpoint = service_cfg
.fetch('defaults', {})
.fetch('hostname', partition['defaults']['hostname'])
+ endpoints = service_cfg.fetch('endpoints', {})
+
# Check for sts legacy behavior
sts_legacy = service == 'sts' &&
sts_regional_endpoints == 'legacy' &&
STS_LEGACY_REGIONS.include?(region)
+ is_global = !endpoints.key?(region) &&
+ service_cfg['isRegionalized'] == false
+
# Check for global endpoint.
- if sts_legacy || service_cfg['isRegionalized'] == false
+ if sts_legacy || is_global
region = service_cfg.fetch('partitionEndpoint', region)
end
# Check for service/region level endpoint.
- endpoint = service_cfg
- .fetch('endpoints', {})
- .fetch(region, {}).fetch('hostname', endpoint)
+ endpoint = endpoints
+ .fetch(region, {})
+ .fetch('hostname', default_endpoint)
# Replace placeholders from the endpoints
endpoint.sub('{region}', region)
.sub('{service}', service)
.sub('{dnsSuffix}', partition['dnsSuffix'])