From 88de69ba28aaedfc7f13fa165044ef8cae023bbe Mon Sep 17 00:00:00 2001 From: Trivikram Kamat <16024985+trivikr@users.noreply.github.com> Date: Wed, 25 Aug 2021 15:29:27 -0700 Subject: [PATCH] feat(clients): modular endpoints resolution (#2704) --- clients/client-accessanalyzer/endpoints.ts | 356 +++------ clients/client-acm-pca/endpoints.ts | 356 +++------ clients/client-acm/endpoints.ts | 356 +++------ .../client-alexa-for-business/endpoints.ts | 141 ++-- clients/client-amp/endpoints.ts | 135 ++-- clients/client-amplify/endpoints.ts | 249 ++---- clients/client-amplifybackend/endpoints.ts | 207 ++--- clients/client-api-gateway/endpoints.ts | 291 ++----- .../endpoints.ts | 135 ++-- clients/client-apigatewayv2/endpoints.ts | 291 ++----- clients/client-app-mesh/endpoints.ts | 255 ++----- clients/client-appconfig/endpoints.ts | 135 ++-- clients/client-appflow/endpoints.ts | 231 ++---- clients/client-appintegrations/endpoints.ts | 183 ++--- .../endpoints.ts | 297 ++------ .../endpoints.ts | 177 ++--- .../client-application-insights/endpoints.ts | 135 ++-- .../endpoints.ts | 135 ++-- clients/client-apprunner/endpoints.ts | 165 ++-- clients/client-appstream/endpoints.ts | 228 ++---- clients/client-appsync/endpoints.ts | 267 ++----- clients/client-athena/endpoints.ts | 356 ++------- clients/client-auditmanager/endpoints.ts | 135 ++-- .../client-auto-scaling-plans/endpoints.ts | 285 ++----- clients/client-auto-scaling/endpoints.ts | 297 ++------ clients/client-backup/endpoints.ts | 285 ++----- clients/client-batch/endpoints.ts | 356 ++------- clients/client-braket/endpoints.ts | 135 ++-- clients/client-budgets/endpoints.ts | 150 ++-- .../client-chime-sdk-identity/endpoints.ts | 154 ++-- .../client-chime-sdk-messaging/endpoints.ts | 154 ++-- clients/client-chime/endpoints.ts | 142 ++-- clients/client-cloud9/endpoints.ts | 249 ++---- clients/client-clouddirectory/endpoints.ts | 195 ++--- clients/client-cloudformation/endpoints.ts | 356 ++------- clients/client-cloudfront/endpoints.ts | 150 ++-- clients/client-cloudhsm-v2/endpoints.ts | 292 ++------ clients/client-cloudhsm/endpoints.ts | 201 ++--- .../client-cloudsearch-domain/endpoints.ts | 135 ++-- clients/client-cloudsearch/endpoints.ts | 195 ++--- clients/client-cloudtrail/endpoints.ts | 350 ++------- clients/client-cloudwatch-events/endpoints.ts | 356 ++------- clients/client-cloudwatch-logs/endpoints.ts | 356 ++------- clients/client-cloudwatch/endpoints.ts | 368 ++------- clients/client-codeartifact/endpoints.ts | 213 ++---- clients/client-codebuild/endpoints.ts | 356 ++------- clients/client-codecommit/endpoints.ts | 292 ++------ clients/client-codedeploy/endpoints.ts | 368 ++------- clients/client-codeguru-reviewer/endpoints.ts | 195 ++--- clients/client-codeguruprofiler/endpoints.ts | 135 ++-- clients/client-codepipeline/endpoints.ts | 321 +++----- .../client-codestar-connections/endpoints.ts | 231 ++---- .../endpoints.ts | 135 ++-- clients/client-codestar/endpoints.ts | 213 ++---- .../endpoints.ts | 303 ++------ clients/client-cognito-identity/endpoints.ts | 297 ++------ clients/client-cognito-sync/endpoints.ts | 201 ++--- clients/client-comprehend/endpoints.ts | 267 ++----- clients/client-comprehendmedical/endpoints.ts | 231 ++---- clients/client-compute-optimizer/endpoints.ts | 135 ++-- clients/client-config-service/endpoints.ts | 368 ++------- .../client-connect-contact-lens/endpoints.ts | 177 ++--- clients/client-connect/endpoints.ts | 189 ++--- .../client-connectparticipant/endpoints.ts | 135 ++-- .../endpoints.ts | 147 ++-- clients/client-cost-explorer/endpoints.ts | 150 ++-- clients/client-customer-profiles/endpoints.ts | 183 ++--- clients/client-data-pipeline/endpoints.ts | 171 ++--- .../endpoints.ts | 310 ++------ clients/client-databrew/endpoints.ts | 135 ++-- clients/client-dataexchange/endpoints.ts | 201 ++--- clients/client-datasync/endpoints.ts | 356 +++------ clients/client-dax/endpoints.ts | 225 ++---- clients/client-detective/endpoints.ts | 338 ++------- clients/client-device-farm/endpoints.ts | 141 ++-- clients/client-devops-guru/endpoints.ts | 135 ++-- clients/client-direct-connect/endpoints.ts | 356 ++------- clients/client-directory-service/endpoints.ts | 380 +++------- clients/client-dlm/endpoints.ts | 135 ++-- clients/client-docdb/endpoints.ts | 380 +++------- clients/client-dynamodb-streams/endpoints.ts | 397 +++------- clients/client-dynamodb/endpoints.ts | 392 +++------- clients/client-ebs/endpoints.ts | 346 ++------- .../client-ec2-instance-connect/endpoints.ts | 135 ++-- clients/client-ec2/endpoints.ts | 368 +++------ clients/client-ecr-public/endpoints.ts | 135 ++-- clients/client-ecr/endpoints.ts | 580 ++++++-------- clients/client-ecs/endpoints.ts | 368 ++------- clients/client-efs/endpoints.ts | 599 +++++---------- clients/client-eks/endpoints.ts | 356 ++------- clients/client-elastic-beanstalk/endpoints.ts | 344 ++------- clients/client-elastic-inference/endpoints.ts | 190 ++--- .../endpoints.ts | 368 ++------- .../endpoints.ts | 368 ++------- .../client-elastic-transcoder/endpoints.ts | 183 ++--- clients/client-elasticache/endpoints.ts | 310 ++------ .../client-elasticsearch-service/endpoints.ts | 310 ++------ clients/client-emr-containers/endpoints.ts | 292 ++------ clients/client-emr/endpoints.ts | 380 +++------- clients/client-eventbridge/endpoints.ts | 356 ++------- clients/client-finspace-data/endpoints.ts | 165 ++-- clients/client-finspace/endpoints.ts | 165 ++-- clients/client-firehose/endpoints.ts | 362 ++------- clients/client-fis/endpoints.ts | 135 ++-- clients/client-fms/endpoints.ts | 524 ++++--------- clients/client-forecast/endpoints.ts | 232 ++---- clients/client-forecastquery/endpoints.ts | 232 ++---- clients/client-frauddetector/endpoints.ts | 135 ++-- clients/client-fsx/endpoints.ts | 368 +++------ clients/client-gamelift/endpoints.ts | 267 ++----- clients/client-glacier/endpoints.ts | 368 +++------ .../client-global-accelerator/endpoints.ts | 135 ++-- clients/client-glue/endpoints.ts | 356 ++------- clients/client-greengrass/endpoints.ts | 269 ++----- clients/client-greengrassv2/endpoints.ts | 269 ++----- clients/client-groundstation/endpoints.ts | 232 ++---- clients/client-guardduty/endpoints.ts | 356 ++------- clients/client-health/endpoints.ts | 183 ++--- clients/client-healthlake/endpoints.ts | 153 ++-- clients/client-honeycode/endpoints.ts | 141 ++-- clients/client-iam/endpoints.ts | 197 +++-- clients/client-identitystore/endpoints.ts | 213 ++---- clients/client-imagebuilder/endpoints.ts | 135 ++-- clients/client-inspector/endpoints.ts | 290 ++----- .../endpoints.ts | 135 ++-- .../client-iot-1click-projects/endpoints.ts | 177 ++--- clients/client-iot-data-plane/endpoints.ts | 376 +++------- clients/client-iot-events-data/endpoints.ts | 135 ++-- clients/client-iot-events/endpoints.ts | 201 ++--- .../client-iot-jobs-data-plane/endpoints.ts | 135 ++-- clients/client-iot-wireless/endpoints.ts | 135 ++-- clients/client-iot/endpoints.ts | 376 +++------- clients/client-iotanalytics/endpoints.ts | 183 ++--- clients/client-iotdeviceadvisor/endpoints.ts | 135 ++-- clients/client-iotfleethub/endpoints.ts | 262 ++----- .../client-iotsecuretunneling/endpoints.ts | 135 ++-- clients/client-iotsitewise/endpoints.ts | 135 ++-- clients/client-iotthingsgraph/endpoints.ts | 179 ++--- clients/client-ivs/endpoints.ts | 135 ++-- clients/client-kafka/endpoints.ts | 273 ++----- clients/client-kendra/endpoints.ts | 135 ++-- .../client-kinesis-analytics-v2/endpoints.ts | 273 ++----- clients/client-kinesis-analytics/endpoints.ts | 273 ++----- .../endpoints.ts | 225 ++---- .../client-kinesis-video-media/endpoints.ts | 225 ++---- .../endpoints.ts | 225 ++---- clients/client-kinesis-video/endpoints.ts | 225 ++---- clients/client-kinesis/endpoints.ts | 356 ++------- clients/client-kms/endpoints.ts | 309 ++------ clients/client-lakeformation/endpoints.ts | 333 ++------- clients/client-lambda/endpoints.ts | 368 ++------- .../endpoints.ts | 237 ++---- clients/client-lex-models-v2/endpoints.ts | 135 ++-- .../client-lex-runtime-service/endpoints.ts | 237 ++---- clients/client-lex-runtime-v2/endpoints.ts | 135 ++-- clients/client-license-manager/endpoints.ts | 368 ++------- clients/client-lightsail/endpoints.ts | 219 ++---- clients/client-location/endpoints.ts | 135 ++-- clients/client-lookoutequipment/endpoints.ts | 153 ++-- clients/client-lookoutmetrics/endpoints.ts | 135 ++-- clients/client-lookoutvision/endpoints.ts | 177 ++--- clients/client-machine-learning/endpoints.ts | 147 ++-- clients/client-macie/endpoints.ts | 172 ++--- clients/client-macie2/endpoints.ts | 310 ++------ clients/client-managedblockchain/endpoints.ts | 171 ++--- .../client-marketplace-catalog/endpoints.ts | 135 ++-- .../endpoints.ts | 141 ++-- .../endpoints.ts | 144 ++-- .../client-marketplace-metering/endpoints.ts | 299 ++------ clients/client-mediaconnect/endpoints.ts | 231 ++---- clients/client-mediaconvert/endpoints.ts | 314 +++----- clients/client-medialive/endpoints.ts | 262 ++----- clients/client-mediapackage-vod/endpoints.ts | 135 ++-- clients/client-mediapackage/endpoints.ts | 231 ++---- clients/client-mediastore-data/endpoints.ts | 189 ++--- clients/client-mediastore/endpoints.ts | 189 ++--- clients/client-mediatailor/endpoints.ts | 177 ++--- clients/client-memorydb/endpoints.ts | 135 ++-- clients/client-mgn/endpoints.ts | 135 ++-- clients/client-migration-hub/endpoints.ts | 177 ++--- .../client-migrationhub-config/endpoints.ts | 135 ++-- clients/client-mobile/endpoints.ts | 135 ++-- clients/client-mq/endpoints.ts | 350 ++------- clients/client-mturk/endpoints.ts | 152 ++-- clients/client-mwaa/endpoints.ts | 189 ++--- clients/client-neptune/endpoints.ts | 380 +++------- clients/client-network-firewall/endpoints.ts | 135 ++-- clients/client-networkmanager/endpoints.ts | 135 ++-- clients/client-nimble/endpoints.ts | 135 ++-- clients/client-opsworks/endpoints.ts | 225 ++---- clients/client-opsworkscm/endpoints.ts | 189 ++--- clients/client-organizations/endpoints.ts | 181 ++--- clients/client-outposts/endpoints.ts | 350 +++------ .../client-personalize-events/endpoints.ts | 135 ++-- .../client-personalize-runtime/endpoints.ts | 135 ++-- clients/client-personalize/endpoints.ts | 207 ++--- clients/client-pi/endpoints.ts | 135 ++-- clients/client-pinpoint-email/endpoints.ts | 189 ++--- .../client-pinpoint-sms-voice/endpoints.ts | 135 ++-- clients/client-pinpoint/endpoints.ts | 270 ++----- clients/client-polly/endpoints.ts | 315 ++------ clients/client-pricing/endpoints.ts | 151 ++-- clients/client-proton/endpoints.ts | 135 ++-- clients/client-qldb-session/endpoints.ts | 232 ++---- clients/client-qldb/endpoints.ts | 232 ++---- clients/client-quicksight/endpoints.ts | 135 ++-- clients/client-ram/endpoints.ts | 362 +++------ clients/client-rds-data/endpoints.ts | 135 ++-- clients/client-rds/endpoints.ts | 380 +++------- clients/client-redshift-data/endpoints.ts | 135 ++-- clients/client-redshift/endpoints.ts | 368 +++------ clients/client-rekognition/endpoints.ts | 291 +++---- .../endpoints.ts | 291 ++----- clients/client-resource-groups/endpoints.ts | 356 ++------- clients/client-robomaker/endpoints.ts | 177 ++--- clients/client-route-53-domains/endpoints.ts | 141 ++-- clients/client-route-53/endpoints.ts | 197 +++-- .../endpoints.ts | 135 ++-- .../endpoints.ts | 148 ++-- .../endpoints.ts | 135 ++-- clients/client-route53resolver/endpoints.ts | 285 ++----- clients/client-s3-control/endpoints.ts | 449 +++++------ clients/client-s3/endpoints.ts | 685 ++++++----------- clients/client-s3outposts/endpoints.ts | 135 ++-- .../client-sagemaker-a2i-runtime/endpoints.ts | 135 ++-- clients/client-sagemaker-edge/endpoints.ts | 135 ++-- .../endpoints.ts | 135 ++-- clients/client-sagemaker-runtime/endpoints.ts | 339 ++------- clients/client-sagemaker/endpoints.ts | 350 ++------- clients/client-savingsplans/endpoints.ts | 142 ++-- clients/client-schemas/endpoints.ts | 237 ++---- clients/client-secrets-manager/endpoints.ts | 362 ++------- clients/client-securityhub/endpoints.ts | 356 ++------- .../endpoints.ts | 278 ++----- .../endpoints.ts | 350 +++------ clients/client-service-catalog/endpoints.ts | 356 ++------- clients/client-service-quotas/endpoints.ts | 296 ++------ clients/client-servicediscovery/endpoints.ts | 280 ++----- clients/client-ses/endpoints.ts | 189 ++--- clients/client-sesv2/endpoints.ts | 189 ++--- clients/client-sfn/endpoints.ts | 368 ++------- clients/client-shield/endpoints.ts | 154 ++-- clients/client-signer/endpoints.ts | 135 ++-- clients/client-sms/endpoints.ts | 350 ++------- .../endpoints.ts | 135 ++-- clients/client-snowball/endpoints.ts | 528 ++++--------- clients/client-sns/endpoints.ts | 356 ++------- clients/client-sqs/endpoints.ts | 356 ++------- clients/client-ssm-contacts/endpoints.ts | 135 ++-- clients/client-ssm-incidents/endpoints.ts | 135 ++-- clients/client-ssm/endpoints.ts | 380 +++------- clients/client-sso-admin/endpoints.ts | 135 ++-- clients/client-sso-oidc/endpoints.ts | 290 +++---- clients/client-sso/endpoints.ts | 235 +++--- clients/client-storage-gateway/endpoints.ts | 298 ++------ clients/client-sts/endpoints.ts | 380 +++------- clients/client-support/endpoints.ts | 203 ++--- clients/client-swf/endpoints.ts | 356 ++------- clients/client-synthetics/endpoints.ts | 135 ++-- clients/client-textract/endpoints.ts | 135 ++-- clients/client-timestream-query/endpoints.ts | 135 ++-- clients/client-timestream-write/endpoints.ts | 135 ++-- .../client-transcribe-streaming/endpoints.ts | 219 ++---- clients/client-transcribe/endpoints.ts | 348 +++------ clients/client-transfer/endpoints.ts | 362 +++------ clients/client-translate/endpoints.ts | 291 ++----- clients/client-waf-regional/endpoints.ts | 707 +++++++----------- clients/client-waf/endpoints.ts | 154 ++-- clients/client-wafv2/endpoints.ts | 135 ++-- clients/client-wellarchitected/endpoints.ts | 135 ++-- clients/client-workdocs/endpoints.ts | 196 ++--- clients/client-worklink/endpoints.ts | 135 ++-- clients/client-workmail/endpoints.ts | 153 ++-- .../client-workmailmessageflow/endpoints.ts | 135 ++-- clients/client-workspaces/endpoints.ts | 261 ++----- clients/client-xray/endpoints.ts | 356 ++------- .../typescript/codegen/EndpointGenerator.java | 162 ++-- protocol_tests/aws-ec2/endpoints.ts | 135 ++-- protocol_tests/aws-json-10/endpoints.ts | 135 ++-- protocol_tests/aws-json/endpoints.ts | 135 ++-- protocol_tests/aws-query/endpoints.ts | 135 ++-- protocol_tests/aws-restjson/endpoints.ts | 135 ++-- protocol_tests/aws-restxml/endpoints.ts | 135 ++-- 283 files changed, 19225 insertions(+), 48054 deletions(-) diff --git a/clients/client-accessanalyzer/endpoints.ts b/clients/client-accessanalyzer/endpoints.ts index ff24a8ca4bf11..f467522eddbc3 100644 --- a/clients/client-accessanalyzer/endpoints.ts +++ b/clients/client-accessanalyzer/endpoints.ts @@ -1,271 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "access-analyzer.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "access-analyzer.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "access-analyzer.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "access-analyzer.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "access-analyzer.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "access-analyzer-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "access-analyzer-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "access-analyzer-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "access-analyzer-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "access-analyzer-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "access-analyzer.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "access-analyzer.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "access-analyzer.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "access-analyzer.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "access-analyzer.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "access-analyzer.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "access-analyzer.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "access-analyzer.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "access-analyzer.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "access-analyzer.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "access-analyzer.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "access-analyzer.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "access-analyzer.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "access-analyzer.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "access-analyzer.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "access-analyzer.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "access-analyzer.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "access-analyzer.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "access-analyzer.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "access-analyzer-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "access-analyzer-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "access-analyzer-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "access-analyzer-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "access-analyzer-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "access-analyzer.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "access-analyzer.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "access-analyzer.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "access-analyzer.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "access-analyzer.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "access-analyzer.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "access-analyzer.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "access-analyzer.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "access-analyzer", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "access-analyzer.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "access-analyzer.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "access-analyzer.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "access-analyzer.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "access-analyzer.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "access-analyzer", + regionHash, + partitionHash, + }); diff --git a/clients/client-acm-pca/endpoints.ts b/clients/client-acm-pca/endpoints.ts index 08883d2d4868a..fc308b2e0b9d1 100644 --- a/clients/client-acm-pca/endpoints.ts +++ b/clients/client-acm-pca/endpoints.ts @@ -1,271 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "acm-pca.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "acm-pca.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "acm-pca.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "acm-pca.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "acm-pca.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "acm-pca-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "acm-pca-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "acm-pca-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "acm-pca.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "acm-pca.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "acm-pca-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "acm-pca-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "acm-pca.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "acm-pca.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "acm-pca.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "acm-pca.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "acm-pca.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "acm-pca.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "acm-pca.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "acm-pca.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "acm-pca.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "acm-pca.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "acm-pca.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "acm-pca.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "acm-pca.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "acm-pca.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "acm-pca.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "acm-pca-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "acm-pca-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "acm-pca-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "acm-pca.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "acm-pca.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "acm-pca-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "acm-pca-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "acm-pca.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "acm-pca.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "acm-pca.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "acm-pca.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "acm-pca.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "acm-pca.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "acm-pca.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "acm-pca.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "acm-pca", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "acm-pca.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "acm-pca.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "acm-pca.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "acm-pca.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "acm-pca.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "acm-pca", + regionHash, + partitionHash, + }); diff --git a/clients/client-acm/endpoints.ts b/clients/client-acm/endpoints.ts index d84d0a6bb12c0..438bec069b372 100644 --- a/clients/client-acm/endpoints.ts +++ b/clients/client-acm/endpoints.ts @@ -1,271 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "acm.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "acm.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "acm.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "acm.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "acm.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "ca-central-1-fips": { + hostname: "acm-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "us-east-1-fips": { + hostname: "acm-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "acm-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1": { + hostname: "acm.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "acm.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "acm-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "acm-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "acm.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "acm.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "acm.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "acm.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "acm.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "acm.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "acm.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "acm.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "acm.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1-fips": - regionInfo = { - hostname: "acm-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "acm.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "acm.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "acm.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "acm.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "acm.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "acm.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "acm.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "acm.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "acm.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "acm.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "acm.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "acm-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "acm.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "acm-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "acm.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "acm.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "acm.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "acm-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "acm.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "acm-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "acm", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "ca-central-1-fips", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "acm.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "acm.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "acm.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "acm.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "acm.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "acm", + regionHash, + partitionHash, + }); diff --git a/clients/client-alexa-for-business/endpoints.ts b/clients/client-alexa-for-business/endpoints.ts index dccf4bfff541a..696615367c93a 100644 --- a/clients/client-alexa-for-business/endpoints.ts +++ b/clients/client-alexa-for-business/endpoints.ts @@ -1,90 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "a4b.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "a4b.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "a4b.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "a4b.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "a4b.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "us-east-1": - regionInfo = { - hostname: "a4b.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "a4b", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "a4b.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "a4b.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "a4b.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "a4b.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "a4b.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "a4b", + regionHash, + partitionHash, + }); diff --git a/clients/client-amp/endpoints.ts b/clients/client-amp/endpoints.ts index f1b06533a5d92..be5973c148e00 100644 --- a/clients/client-amp/endpoints.ts +++ b/clients/client-amp/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "aps.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "aps.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "aps.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "aps.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "aps.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "aps", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "aps.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "aps.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "aps.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "aps.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "aps.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "aps", + regionHash, + partitionHash, + }); diff --git a/clients/client-amplify/endpoints.ts b/clients/client-amplify/endpoints.ts index dfb56f608efb2..7531b61e60154 100644 --- a/clients/client-amplify/endpoints.ts +++ b/clients/client-amplify/endpoints.ts @@ -1,198 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "amplify.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "amplify.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "amplify.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "amplify.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "amplify.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "amplify.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "amplify.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "amplify.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "amplify.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "amplify.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "amplify.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "amplify.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "amplify.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "amplify.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "amplify.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "amplify.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "amplify.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "amplify.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "amplify.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "amplify.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "amplify.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "amplify.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "amplify.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "amplify.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "amplify", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "amplify.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "amplify.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "amplify.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "amplify.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "amplify.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "amplify", + regionHash, + partitionHash, + }); diff --git a/clients/client-amplifybackend/endpoints.ts b/clients/client-amplifybackend/endpoints.ts index 28c8f4b7d7039..915528cf61538 100644 --- a/clients/client-amplifybackend/endpoints.ts +++ b/clients/client-amplifybackend/endpoints.ts @@ -1,156 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "amplifybackend.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "amplifybackend.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "amplifybackend.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "amplifybackend.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "amplifybackend.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "amplifybackend.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "amplifybackend.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "amplifybackend.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "amplifybackend.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "amplifybackend.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "amplifybackend.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "amplifybackend.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "amplifybackend.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "amplifybackend.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "amplifybackend.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "amplifybackend.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "amplifybackend.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "amplifybackend", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "amplifybackend.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "amplifybackend.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "amplifybackend.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "amplifybackend.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "amplifybackend.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "amplifybackend", + regionHash, + partitionHash, + }); diff --git a/clients/client-api-gateway/endpoints.ts b/clients/client-api-gateway/endpoints.ts index 29a47ee1ab7e8..b1fe321bb60ba 100644 --- a/clients/client-api-gateway/endpoints.ts +++ b/clients/client-api-gateway/endpoints.ts @@ -1,240 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "apigateway.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "apigateway.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "apigateway.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "apigateway.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "apigateway.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "apigateway.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "apigateway.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "apigateway.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "apigateway.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "apigateway.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "apigateway.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "apigateway.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "apigateway.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "apigateway.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "apigateway.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "apigateway.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "apigateway.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "apigateway.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "apigateway.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "apigateway.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "apigateway.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "apigateway.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "apigateway.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "apigateway.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "apigateway.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "apigateway.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "apigateway.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "apigateway.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "apigateway.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "apigateway.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "apigateway.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "apigateway", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "apigateway.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "apigateway.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "apigateway.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "apigateway.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "apigateway.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "apigateway", + regionHash, + partitionHash, + }); diff --git a/clients/client-apigatewaymanagementapi/endpoints.ts b/clients/client-apigatewaymanagementapi/endpoints.ts index 956bd557cf37c..4f7a196b9b134 100644 --- a/clients/client-apigatewaymanagementapi/endpoints.ts +++ b/clients/client-apigatewaymanagementapi/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "execute-api.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "execute-api.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "execute-api.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "execute-api.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "execute-api.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "execute-api", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "execute-api.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "execute-api.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "execute-api.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "execute-api.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "execute-api.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "execute-api", + regionHash, + partitionHash, + }); diff --git a/clients/client-apigatewayv2/endpoints.ts b/clients/client-apigatewayv2/endpoints.ts index 29a47ee1ab7e8..b1fe321bb60ba 100644 --- a/clients/client-apigatewayv2/endpoints.ts +++ b/clients/client-apigatewayv2/endpoints.ts @@ -1,240 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "apigateway.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "apigateway.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "apigateway.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "apigateway.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "apigateway.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "apigateway.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "apigateway.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "apigateway.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "apigateway.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "apigateway.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "apigateway.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "apigateway.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "apigateway.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "apigateway.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "apigateway.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "apigateway.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "apigateway.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "apigateway.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "apigateway.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "apigateway.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "apigateway.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "apigateway.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "apigateway.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "apigateway.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "apigateway.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "apigateway.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "apigateway.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "apigateway.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "apigateway.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "apigateway.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "apigateway.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "apigateway", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "apigateway.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "apigateway.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "apigateway.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "apigateway.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "apigateway.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "apigateway", + regionHash, + partitionHash, + }); diff --git a/clients/client-app-mesh/endpoints.ts b/clients/client-app-mesh/endpoints.ts index e4b9b781aaf50..3e27ae86ed216 100644 --- a/clients/client-app-mesh/endpoints.ts +++ b/clients/client-app-mesh/endpoints.ts @@ -1,204 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "appmesh.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "appmesh.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "appmesh.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "appmesh.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "appmesh.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "appmesh.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "appmesh.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "appmesh.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "appmesh.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "appmesh.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "appmesh.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "appmesh.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "appmesh.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "appmesh.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "appmesh.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "appmesh.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "appmesh.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "appmesh.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "appmesh.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "appmesh.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "appmesh.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "appmesh.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "appmesh.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "appmesh.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "appmesh.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "appmesh", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "appmesh.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "appmesh.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "appmesh.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "appmesh.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "appmesh.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "appmesh", + regionHash, + partitionHash, + }); diff --git a/clients/client-appconfig/endpoints.ts b/clients/client-appconfig/endpoints.ts index 4b84b92aaafd1..2e0566d8efa62 100644 --- a/clients/client-appconfig/endpoints.ts +++ b/clients/client-appconfig/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "appconfig.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "appconfig.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "appconfig.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "appconfig.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "appconfig.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "appconfig", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "appconfig.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "appconfig.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "appconfig.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "appconfig.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "appconfig.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "appconfig", + regionHash, + partitionHash, + }); diff --git a/clients/client-appflow/endpoints.ts b/clients/client-appflow/endpoints.ts index 966a491b85b2b..12eaf5cc760aa 100644 --- a/clients/client-appflow/endpoints.ts +++ b/clients/client-appflow/endpoints.ts @@ -1,180 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "appflow.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "appflow.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "appflow.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "appflow.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "appflow.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "appflow.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "appflow.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "appflow.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "appflow.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "appflow.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "appflow.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "appflow.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "appflow.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "appflow.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "appflow.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "appflow.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "appflow.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "appflow.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "appflow.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "appflow.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "appflow.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "appflow", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "appflow.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "appflow.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "appflow.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "appflow.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "appflow.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "appflow", + regionHash, + partitionHash, + }); diff --git a/clients/client-appintegrations/endpoints.ts b/clients/client-appintegrations/endpoints.ts index 0353883f70c6e..36ed320f43949 100644 --- a/clients/client-appintegrations/endpoints.ts +++ b/clients/client-appintegrations/endpoints.ts @@ -1,132 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "app-integrations.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "app-integrations.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "app-integrations.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "app-integrations.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "app-integrations.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "app-integrations.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "app-integrations.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "app-integrations.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "app-integrations.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "app-integrations.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "app-integrations.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "app-integrations.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "app-integrations.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "app-integrations", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "app-integrations.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "app-integrations.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "app-integrations.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "app-integrations.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "app-integrations.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "app-integrations", + regionHash, + partitionHash, + }); diff --git a/clients/client-application-auto-scaling/endpoints.ts b/clients/client-application-auto-scaling/endpoints.ts index f2ac3a89aa446..12c87a75dc52a 100644 --- a/clients/client-application-auto-scaling/endpoints.ts +++ b/clients/client-application-auto-scaling/endpoints.ts @@ -1,246 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "application-autoscaling.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "application-autoscaling.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "application-autoscaling.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "application-autoscaling.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "application-autoscaling.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "application-autoscaling.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "application-autoscaling.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "application-autoscaling.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "application-autoscaling.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "application-autoscaling.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "application-autoscaling.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "application-autoscaling.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "application-autoscaling.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "application-autoscaling.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "application-autoscaling.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "application-autoscaling.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "application-autoscaling.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "application-autoscaling.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "application-autoscaling.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "application-autoscaling.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "application-autoscaling.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "application-autoscaling.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "application-autoscaling.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "application-autoscaling.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "application-autoscaling.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "application-autoscaling.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "application-autoscaling.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "application-autoscaling.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "application-autoscaling.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "application-autoscaling.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "application-autoscaling.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "application-autoscaling.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "application-autoscaling", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "application-autoscaling.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "application-autoscaling.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "application-autoscaling.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "application-autoscaling.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "application-autoscaling.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "application-autoscaling", + regionHash, + partitionHash, + }); diff --git a/clients/client-application-discovery-service/endpoints.ts b/clients/client-application-discovery-service/endpoints.ts index 120b96b2e158d..646824ed9ccbf 100644 --- a/clients/client-application-discovery-service/endpoints.ts +++ b/clients/client-application-discovery-service/endpoints.ts @@ -1,126 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "discovery.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "discovery.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "discovery.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "discovery.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "discovery.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "discovery.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "discovery.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "discovery.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "discovery.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "discovery.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "discovery.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "discovery.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "discovery", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "discovery.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "discovery.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "discovery.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "discovery.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "discovery.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "discovery", + regionHash, + partitionHash, + }); diff --git a/clients/client-application-insights/endpoints.ts b/clients/client-application-insights/endpoints.ts index e4ade300bdff5..d0107aeeaf77d 100644 --- a/clients/client-application-insights/endpoints.ts +++ b/clients/client-application-insights/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "applicationinsights.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "applicationinsights.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "applicationinsights.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "applicationinsights.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "applicationinsights.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "applicationinsights", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "applicationinsights.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "applicationinsights.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "applicationinsights.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "applicationinsights.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "applicationinsights.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "applicationinsights", + regionHash, + partitionHash, + }); diff --git a/clients/client-applicationcostprofiler/endpoints.ts b/clients/client-applicationcostprofiler/endpoints.ts index 45e024b0b6c79..a99ea23f62da5 100644 --- a/clients/client-applicationcostprofiler/endpoints.ts +++ b/clients/client-applicationcostprofiler/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "application-cost-profiler.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "application-cost-profiler.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "application-cost-profiler.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "application-cost-profiler.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "application-cost-profiler.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "application-cost-profiler", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "application-cost-profiler.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "application-cost-profiler.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "application-cost-profiler.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "application-cost-profiler.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "application-cost-profiler.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "application-cost-profiler", + regionHash, + partitionHash, + }); diff --git a/clients/client-apprunner/endpoints.ts b/clients/client-apprunner/endpoints.ts index 8e48c6af90051..3e2911d66ef09 100644 --- a/clients/client-apprunner/endpoints.ts +++ b/clients/client-apprunner/endpoints.ts @@ -1,114 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "apprunner.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "apprunner.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "apprunner.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "apprunner.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "apprunner.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "apprunner.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "apprunner.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "apprunner.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "apprunner.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "apprunner.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "apprunner", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "apprunner.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "apprunner.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "apprunner.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "apprunner.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "apprunner.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "apprunner", + regionHash, + partitionHash, + }); diff --git a/clients/client-appstream/endpoints.ts b/clients/client-appstream/endpoints.ts index 3d69535799355..73ae84fb14253 100644 --- a/clients/client-appstream/endpoints.ts +++ b/clients/client-appstream/endpoints.ts @@ -1,171 +1,63 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "appstream2.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "appstream2.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "appstream2.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "appstream2.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "appstream2.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + fips: { + hostname: "appstream2-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "appstream2.ap-northeast-1.amazonaws.com", - partition: "aws", - signingService: "appstream", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "appstream2.ap-northeast-2.amazonaws.com", - partition: "aws", - signingService: "appstream", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "appstream2.ap-south-1.amazonaws.com", - partition: "aws", - signingService: "appstream", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "appstream2.ap-southeast-1.amazonaws.com", - partition: "aws", - signingService: "appstream", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "appstream2.ap-southeast-2.amazonaws.com", - partition: "aws", - signingService: "appstream", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "appstream2.eu-central-1.amazonaws.com", - partition: "aws", - signingService: "appstream", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "appstream2.eu-west-1.amazonaws.com", - partition: "aws", - signingService: "appstream", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "appstream2.eu-west-2.amazonaws.com", - partition: "aws", - signingService: "appstream", - }; - break; - case "fips": - regionInfo = { - hostname: "appstream2-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "appstream2.us-east-1.amazonaws.com", - partition: "aws", - signingService: "appstream", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "appstream2.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "appstream", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "appstream2.us-west-2.amazonaws.com", - partition: "aws", - signingService: "appstream", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "appstream", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - signingService: "appstream", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "appstream", - }; - } - } - return Promise.resolve({ signingService: "appstream", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "appstream2.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "appstream2.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "appstream2.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "appstream2.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips", "us-gov-east-1", "us-gov-west-1"], + hostname: "appstream2.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "appstream", + regionHash, + partitionHash, + }); diff --git a/clients/client-appsync/endpoints.ts b/clients/client-appsync/endpoints.ts index edb03474e5700..8d9e1128412f0 100644 --- a/clients/client-appsync/endpoints.ts +++ b/clients/client-appsync/endpoints.ts @@ -1,216 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "appsync.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "appsync.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "appsync.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "appsync.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "appsync.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "appsync.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "appsync.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "appsync.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "appsync.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "appsync.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "appsync.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "appsync.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "appsync.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "appsync.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "appsync.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "appsync.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "appsync.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "appsync.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "appsync.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "appsync.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "appsync.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "appsync.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "appsync.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "appsync.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "appsync.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "appsync.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "appsync.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "appsync", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "appsync.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "appsync.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "appsync.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "appsync.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "appsync.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "appsync", + regionHash, + partitionHash, + }); diff --git a/clients/client-athena/endpoints.ts b/clients/client-athena/endpoints.ts index ec6cac00484e1..bda55f974cf6c 100644 --- a/clients/client-athena/endpoints.ts +++ b/clients/client-athena/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "athena.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "athena.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "athena.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "athena.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "athena.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "athena-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "athena-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "athena-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "athena-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "athena-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "athena-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "athena.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "athena.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "athena.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "athena.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "athena.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "athena.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "athena.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "athena.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "athena.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "athena.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "athena.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "athena.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "athena.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "athena.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "athena.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "athena.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "athena.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "athena-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "athena-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "athena-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "athena-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "athena-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "athena-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "athena.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "athena.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "athena.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "athena.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "athena.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "athena.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "athena.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "athena.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "athena", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "athena.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "athena.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "athena.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "athena.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "athena.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "athena", + regionHash, + partitionHash, + }); diff --git a/clients/client-auditmanager/endpoints.ts b/clients/client-auditmanager/endpoints.ts index b0c702ebf820a..19fe829e4ef10 100644 --- a/clients/client-auditmanager/endpoints.ts +++ b/clients/client-auditmanager/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "auditmanager.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "auditmanager.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "auditmanager.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "auditmanager.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "auditmanager.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "auditmanager", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "auditmanager.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "auditmanager.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "auditmanager.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "auditmanager.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "auditmanager.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "auditmanager", + regionHash, + partitionHash, + }); diff --git a/clients/client-auto-scaling-plans/endpoints.ts b/clients/client-auto-scaling-plans/endpoints.ts index 4ec1a7c8b2eb7..ebf6ad96e4f53 100644 --- a/clients/client-auto-scaling-plans/endpoints.ts +++ b/clients/client-auto-scaling-plans/endpoints.ts @@ -1,234 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "autoscaling-plans.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "autoscaling-plans.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "autoscaling-plans.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "autoscaling-plans.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "autoscaling-plans.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "autoscaling-plans.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "autoscaling-plans.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "autoscaling-plans.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "autoscaling-plans.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "autoscaling-plans.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "autoscaling-plans.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "autoscaling-plans.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "autoscaling-plans.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "autoscaling-plans.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "autoscaling-plans.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "autoscaling-plans.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "autoscaling-plans.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "autoscaling-plans.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "autoscaling-plans.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "autoscaling-plans.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "autoscaling-plans.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "autoscaling-plans.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "autoscaling-plans.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "autoscaling-plans.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "autoscaling-plans.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "autoscaling-plans.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "autoscaling-plans.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "autoscaling-plans.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "autoscaling-plans.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "autoscaling-plans.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "autoscaling-plans", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "autoscaling-plans.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "autoscaling-plans.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "autoscaling-plans.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "autoscaling-plans.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "autoscaling-plans.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "autoscaling-plans", + regionHash, + partitionHash, + }); diff --git a/clients/client-auto-scaling/endpoints.ts b/clients/client-auto-scaling/endpoints.ts index 8b81e6d97a4c0..cb0b4749c7056 100644 --- a/clients/client-auto-scaling/endpoints.ts +++ b/clients/client-auto-scaling/endpoints.ts @@ -1,246 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "autoscaling.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "autoscaling.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "autoscaling.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "autoscaling.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "autoscaling.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "autoscaling.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "autoscaling.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "autoscaling.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "autoscaling.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "autoscaling.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "autoscaling.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "autoscaling.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "autoscaling.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "autoscaling.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "autoscaling.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "autoscaling.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "autoscaling.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "autoscaling.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "autoscaling.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "autoscaling.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "autoscaling.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "autoscaling.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "autoscaling.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "autoscaling.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "autoscaling.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "autoscaling.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "autoscaling.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "autoscaling.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "autoscaling.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "autoscaling.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "autoscaling.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "autoscaling.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "autoscaling", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "autoscaling.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "autoscaling.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "autoscaling.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "autoscaling.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "autoscaling.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "autoscaling", + regionHash, + partitionHash, + }); diff --git a/clients/client-backup/endpoints.ts b/clients/client-backup/endpoints.ts index 4ba2f8ee7ee67..ff901780f0772 100644 --- a/clients/client-backup/endpoints.ts +++ b/clients/client-backup/endpoints.ts @@ -1,234 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "backup.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "backup.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "backup.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "backup.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "backup.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "backup.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "backup.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "backup.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "backup.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "backup.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "backup.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "backup.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "backup.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "backup.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "backup.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "backup.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "backup.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "backup.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "backup.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "backup.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "backup.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "backup.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "backup.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "backup.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "backup.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "backup.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "backup.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "backup.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "backup.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "backup.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "backup", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "backup.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "backup.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "backup.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "backup.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "backup.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "backup", + regionHash, + partitionHash, + }); diff --git a/clients/client-batch/endpoints.ts b/clients/client-batch/endpoints.ts index db3d3616ae253..19e6f4b457a8d 100644 --- a/clients/client-batch/endpoints.ts +++ b/clients/client-batch/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "batch.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "batch.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "batch.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "batch.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "batch.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "fips.batch.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "fips.batch.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "batch.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "batch.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "fips.batch.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "fips.batch.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "batch.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "batch.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "batch.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "batch.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "batch.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "batch.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "batch.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "batch.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "batch.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "batch.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "batch.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "batch.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "batch.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "batch.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "batch.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "batch.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "batch.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "fips.batch.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "fips.batch.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "batch.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "batch.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "fips.batch.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "fips.batch.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "batch.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "batch.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "batch.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "batch.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "batch.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "batch.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "batch.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "batch.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "batch", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "batch.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "batch.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "batch.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "batch.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "batch.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "batch", + regionHash, + partitionHash, + }); diff --git a/clients/client-braket/endpoints.ts b/clients/client-braket/endpoints.ts index d60ddb4c6d8ee..42988cbbd6e7a 100644 --- a/clients/client-braket/endpoints.ts +++ b/clients/client-braket/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "braket.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "braket.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "braket.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "braket.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "braket.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "braket", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "braket.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "braket.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "braket.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "braket.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "braket.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "braket", + regionHash, + partitionHash, + }); diff --git a/clients/client-budgets/endpoints.ts b/clients/client-budgets/endpoints.ts index 491bc9881ef26..7a63e5d9ada8f 100644 --- a/clients/client-budgets/endpoints.ts +++ b/clients/client-budgets/endpoints.ts @@ -1,89 +1,67 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "budgets.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "budgets.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "budgets.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "budgets.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "budgets.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-cn-global": { + hostname: "budgets.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "aws-global": { + hostname: "budgets.amazonaws.com", + signingRegion: "us-east-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "aws-cn-global": - regionInfo = { - hostname: "budgets.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "aws-global": - regionInfo = { - hostname: "budgets.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-global"); - } - if (AWS_CN_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-cn-global"); - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - return defaultRegionInfoProvider("aws-global"); - } - } - return Promise.resolve({ signingService: "budgets", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + endpoint: "aws-global", + }, + "aws-cn": { + regions: ["aws-cn-global", "cn-north-1", "cn-northwest-1"], + endpoint: "aws-cn-global", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "budgets.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "budgets.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "budgets.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "budgets", + regionHash, + partitionHash, + }); diff --git a/clients/client-chime-sdk-identity/endpoints.ts b/clients/client-chime-sdk-identity/endpoints.ts index ba6ba896a5fdd..5a8eb69e6b3e0 100644 --- a/clients/client-chime-sdk-identity/endpoints.ts +++ b/clients/client-chime-sdk-identity/endpoints.ts @@ -1,97 +1,63 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "identity-chime.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "identity-chime.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "identity-chime.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "identity-chime.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "identity-chime.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "identity-chime-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "us-east-1": - regionInfo = { - hostname: "identity-chime.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "identity-chime-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "chime", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "identity-chime.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "identity-chime.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "identity-chime.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "identity-chime.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "identity-chime.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "chime", + regionHash, + partitionHash, + }); diff --git a/clients/client-chime-sdk-messaging/endpoints.ts b/clients/client-chime-sdk-messaging/endpoints.ts index fd2089436777c..80460d0a82d48 100644 --- a/clients/client-chime-sdk-messaging/endpoints.ts +++ b/clients/client-chime-sdk-messaging/endpoints.ts @@ -1,97 +1,63 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "messaging-chime.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "messaging-chime.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "messaging-chime.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "messaging-chime.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "messaging-chime.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "messaging-chime-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "us-east-1": - regionInfo = { - hostname: "messaging-chime.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "messaging-chime-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "chime", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "messaging-chime.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "messaging-chime.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "messaging-chime.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "messaging-chime.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "messaging-chime.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "chime", + regionHash, + partitionHash, + }); diff --git a/clients/client-chime/endpoints.ts b/clients/client-chime/endpoints.ts index 306c67dcbd046..b50932b098593 100644 --- a/clients/client-chime/endpoints.ts +++ b/clients/client-chime/endpoints.ts @@ -1,85 +1,63 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "chime.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "chime.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "chime.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "chime.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "chime.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-global": { + hostname: "chime.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "aws-global": - regionInfo = { - hostname: "chime.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-global"); - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - return defaultRegionInfoProvider("aws-global"); - } - } - return Promise.resolve({ signingService: "chime", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + endpoint: "aws-global", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "chime.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "chime.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "chime.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "chime.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "chime", + regionHash, + partitionHash, + }); diff --git a/clients/client-cloud9/endpoints.ts b/clients/client-cloud9/endpoints.ts index 643deb6752b74..e67d20cd8c55b 100644 --- a/clients/client-cloud9/endpoints.ts +++ b/clients/client-cloud9/endpoints.ts @@ -1,198 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "cloud9.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "cloud9.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "cloud9.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "cloud9.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "cloud9.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "cloud9.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "cloud9.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "cloud9.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "cloud9.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "cloud9.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "cloud9.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "cloud9.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "cloud9.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "cloud9.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "cloud9.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "cloud9.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "cloud9.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "cloud9.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "cloud9.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "cloud9.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "cloud9.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "cloud9.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "cloud9.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "cloud9.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "cloud9", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "cloud9.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "cloud9.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "cloud9.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "cloud9.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "cloud9.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "cloud9", + regionHash, + partitionHash, + }); diff --git a/clients/client-clouddirectory/endpoints.ts b/clients/client-clouddirectory/endpoints.ts index 9c0431be632a5..86478f2a127c7 100644 --- a/clients/client-clouddirectory/endpoints.ts +++ b/clients/client-clouddirectory/endpoints.ts @@ -1,144 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "clouddirectory.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "clouddirectory.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "clouddirectory.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "clouddirectory.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "clouddirectory.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-southeast-1": - regionInfo = { - hostname: "clouddirectory.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "clouddirectory.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "clouddirectory.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "clouddirectory.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "clouddirectory.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "clouddirectory.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "clouddirectory.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "clouddirectory.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "clouddirectory.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "clouddirectory.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "clouddirectory", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "clouddirectory.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "clouddirectory.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "clouddirectory.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "clouddirectory.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "clouddirectory.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "clouddirectory", + regionHash, + partitionHash, + }); diff --git a/clients/client-cloudformation/endpoints.ts b/clients/client-cloudformation/endpoints.ts index 53321e9775b1b..efea951fca87b 100644 --- a/clients/client-cloudformation/endpoints.ts +++ b/clients/client-cloudformation/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "cloudformation.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "cloudformation.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "cloudformation.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "cloudformation.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "cloudformation.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "cloudformation-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "cloudformation-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1": { + hostname: "cloudformation.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "cloudformation.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "cloudformation-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "cloudformation-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "cloudformation.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "cloudformation.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "cloudformation.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "cloudformation.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "cloudformation.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "cloudformation.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "cloudformation.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "cloudformation.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "cloudformation.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "cloudformation.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "cloudformation.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "cloudformation.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "cloudformation.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "cloudformation.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "cloudformation.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "cloudformation.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "cloudformation.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "cloudformation.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "cloudformation.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "cloudformation.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "cloudformation-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "cloudformation.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "cloudformation-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "cloudformation.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "cloudformation.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "cloudformation.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "cloudformation.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "cloudformation.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "cloudformation-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "cloudformation.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "cloudformation-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "cloudformation", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "cloudformation.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "cloudformation.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "cloudformation.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "cloudformation.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "cloudformation.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "cloudformation", + regionHash, + partitionHash, + }); diff --git a/clients/client-cloudfront/endpoints.ts b/clients/client-cloudfront/endpoints.ts index 319df1cdc410f..2b4d95c6e8b1f 100644 --- a/clients/client-cloudfront/endpoints.ts +++ b/clients/client-cloudfront/endpoints.ts @@ -1,89 +1,67 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "cloudfront.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "cloudfront.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "cloudfront.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "cloudfront.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "cloudfront.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-cn-global": { + hostname: "cloudfront.cn-northwest-1.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "aws-global": { + hostname: "cloudfront.amazonaws.com", + signingRegion: "us-east-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "aws-cn-global": - regionInfo = { - hostname: "cloudfront.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "aws-global": - regionInfo = { - hostname: "cloudfront.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-global"); - } - if (AWS_CN_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-cn-global"); - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - return defaultRegionInfoProvider("aws-global"); - } - } - return Promise.resolve({ signingService: "cloudfront", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + endpoint: "aws-global", + }, + "aws-cn": { + regions: ["aws-cn-global", "cn-north-1", "cn-northwest-1"], + endpoint: "aws-cn-global", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "cloudfront.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "cloudfront.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "cloudfront.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "cloudfront", + regionHash, + partitionHash, + }); diff --git a/clients/client-cloudhsm-v2/endpoints.ts b/clients/client-cloudhsm-v2/endpoints.ts index a53ac9a3659f5..bf6be76d4611a 100644 --- a/clients/client-cloudhsm-v2/endpoints.ts +++ b/clients/client-cloudhsm-v2/endpoints.ts @@ -1,241 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "cloudhsmv2.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "cloudhsmv2.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "cloudhsmv2.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "cloudhsmv2.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "cloudhsmv2.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "cloudhsmv2.af-south-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "cloudhsmv2.ap-east-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "cloudhsmv2.ap-northeast-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "cloudhsmv2.ap-northeast-2.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "cloudhsmv2.ap-south-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "cloudhsmv2.ap-southeast-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "cloudhsmv2.ap-southeast-2.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "cloudhsmv2.ca-central-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "cloudhsmv2.eu-central-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "cloudhsmv2.eu-north-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "cloudhsmv2.eu-south-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "cloudhsmv2.eu-west-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "cloudhsmv2.eu-west-2.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "cloudhsmv2.eu-west-3.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "cloudhsmv2.me-south-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "cloudhsmv2.sa-east-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "cloudhsmv2.us-east-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "cloudhsmv2.us-east-2.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "cloudhsmv2.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "cloudhsm", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "cloudhsmv2.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "cloudhsm", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "cloudhsmv2.us-west-1.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "cloudhsmv2.us-west-2.amazonaws.com", - partition: "aws", - signingService: "cloudhsm", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "cloudhsm", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - signingService: "cloudhsm", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "cloudhsm", - }; - } - } - return Promise.resolve({ signingService: "cloudhsm", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "cloudhsmv2.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "cloudhsmv2.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "cloudhsmv2.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "cloudhsmv2.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "cloudhsmv2.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "cloudhsm", + regionHash, + partitionHash, + }); diff --git a/clients/client-cloudhsm/endpoints.ts b/clients/client-cloudhsm/endpoints.ts index 6fad707f3e4ef..2d7b8d32a3c9e 100644 --- a/clients/client-cloudhsm/endpoints.ts +++ b/clients/client-cloudhsm/endpoints.ts @@ -1,150 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "cloudhsm.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "cloudhsm.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "cloudhsm.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "cloudhsm.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "cloudhsm.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "cloudhsm.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "cloudhsm.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "cloudhsm.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "cloudhsm.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "cloudhsm.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "cloudhsm.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "cloudhsm.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "cloudhsm.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "cloudhsm.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "cloudhsm.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "cloudhsm.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "cloudhsm", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "cloudhsm.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "cloudhsm.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "cloudhsm.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "cloudhsm.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "cloudhsm.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "cloudhsm", + regionHash, + partitionHash, + }); diff --git a/clients/client-cloudsearch-domain/endpoints.ts b/clients/client-cloudsearch-domain/endpoints.ts index b8bb6d6c26eee..be6d200577737 100644 --- a/clients/client-cloudsearch-domain/endpoints.ts +++ b/clients/client-cloudsearch-domain/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "cloudsearchdomain.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "cloudsearchdomain.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "cloudsearchdomain.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "cloudsearchdomain.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "cloudsearchdomain.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "cloudsearch", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "cloudsearchdomain.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "cloudsearchdomain.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "cloudsearchdomain.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "cloudsearchdomain.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "cloudsearchdomain.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "cloudsearch", + regionHash, + partitionHash, + }); diff --git a/clients/client-cloudsearch/endpoints.ts b/clients/client-cloudsearch/endpoints.ts index ff2af49fcf305..115d7e3495dac 100644 --- a/clients/client-cloudsearch/endpoints.ts +++ b/clients/client-cloudsearch/endpoints.ts @@ -1,144 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "cloudsearch.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "cloudsearch.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "cloudsearch.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "cloudsearch.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "cloudsearch.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "cloudsearch.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "cloudsearch.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "cloudsearch.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "cloudsearch.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "cloudsearch.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "cloudsearch.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "cloudsearch.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "cloudsearch.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "cloudsearch.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "cloudsearch.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "cloudsearch", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "cloudsearch.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "cloudsearch.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "cloudsearch.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "cloudsearch.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "cloudsearch.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "cloudsearch", + regionHash, + partitionHash, + }); diff --git a/clients/client-cloudtrail/endpoints.ts b/clients/client-cloudtrail/endpoints.ts index d67e03e9cce93..d125cefc0dd50 100644 --- a/clients/client-cloudtrail/endpoints.ts +++ b/clients/client-cloudtrail/endpoints.ts @@ -1,270 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "cloudtrail.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "cloudtrail.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "cloudtrail.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "cloudtrail.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "cloudtrail.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "cloudtrail-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "cloudtrail-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "cloudtrail-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "cloudtrail-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "cloudtrail.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "cloudtrail.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "cloudtrail.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "cloudtrail.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "cloudtrail.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "cloudtrail.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "cloudtrail.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "cloudtrail.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "cloudtrail.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "cloudtrail.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "cloudtrail.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "cloudtrail.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "cloudtrail.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "cloudtrail.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "cloudtrail.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "cloudtrail.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "cloudtrail.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "cloudtrail.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "cloudtrail-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "cloudtrail-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "cloudtrail-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "cloudtrail-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "cloudtrail.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "cloudtrail.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "cloudtrail.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "cloudtrail.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "cloudtrail.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "cloudtrail.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "cloudtrail.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "cloudtrail.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "cloudtrail.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "cloudtrail.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "cloudtrail", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "cloudtrail.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "cloudtrail.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "cloudtrail.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "cloudtrail.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "cloudtrail.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "cloudtrail", + regionHash, + partitionHash, + }); diff --git a/clients/client-cloudwatch-events/endpoints.ts b/clients/client-cloudwatch-events/endpoints.ts index 118077ce795bf..99dac1f1644e6 100644 --- a/clients/client-cloudwatch-events/endpoints.ts +++ b/clients/client-cloudwatch-events/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "events.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "events.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "events.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "events.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "events.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "events-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "events-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "events-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "events-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "events.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "events.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "events.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "events.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "events.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "events.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "events.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "events.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "events.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "events.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "events.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "events.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "events.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "events.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "events.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "events.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "events.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "events.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "events.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "events-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "events-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "events-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "events-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "events.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "events.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "events.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "events.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "events.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "events.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "events.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "events.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "events.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "events.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "events", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "events.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "events.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "events.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "events.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "events.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "events", + regionHash, + partitionHash, + }); diff --git a/clients/client-cloudwatch-logs/endpoints.ts b/clients/client-cloudwatch-logs/endpoints.ts index aefaf63f3dd85..fde1cd3995c24 100644 --- a/clients/client-cloudwatch-logs/endpoints.ts +++ b/clients/client-cloudwatch-logs/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "logs.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "logs.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "logs.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "logs.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "logs.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "logs-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "logs-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "logs-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "logs-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "logs.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "logs.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "logs.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "logs.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "logs.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "logs.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "logs.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "logs.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "logs.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "logs.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "logs.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "logs.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "logs.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "logs.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "logs.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "logs.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "logs.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "logs.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "logs.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "logs-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "logs-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "logs-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "logs-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "logs.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "logs.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "logs.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "logs.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "logs.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "logs.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "logs.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "logs.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "logs.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "logs.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "logs", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "logs.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "logs.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "logs.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "logs.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "logs.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "logs", + regionHash, + partitionHash, + }); diff --git a/clients/client-cloudwatch/endpoints.ts b/clients/client-cloudwatch/endpoints.ts index 9ba1acf77eb89..736bfc318ee1f 100644 --- a/clients/client-cloudwatch/endpoints.ts +++ b/clients/client-cloudwatch/endpoints.ts @@ -1,288 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "monitoring.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "monitoring.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "monitoring.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "monitoring.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "monitoring.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "monitoring-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "monitoring-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "monitoring.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "monitoring.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "monitoring-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "monitoring-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "monitoring.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "monitoring.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "monitoring.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "monitoring.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "monitoring.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "monitoring.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "monitoring.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "monitoring.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "monitoring.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "monitoring.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "monitoring.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "monitoring.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "monitoring.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "monitoring.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "monitoring.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "monitoring.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "monitoring.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "monitoring-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "monitoring-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "monitoring.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "monitoring.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "monitoring-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "monitoring-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "monitoring.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "monitoring.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "monitoring.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "monitoring.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "monitoring.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "monitoring.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "monitoring.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "monitoring.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "monitoring.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "monitoring.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "monitoring", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "monitoring.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "monitoring.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "monitoring.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "monitoring.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "monitoring.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "monitoring", + regionHash, + partitionHash, + }); diff --git a/clients/client-codeartifact/endpoints.ts b/clients/client-codeartifact/endpoints.ts index e568bb5169934..272f6d4c14dce 100644 --- a/clients/client-codeartifact/endpoints.ts +++ b/clients/client-codeartifact/endpoints.ts @@ -1,162 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "codeartifact.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "codeartifact.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "codeartifact.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "codeartifact.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "codeartifact.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "codeartifact.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "codeartifact.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "codeartifact.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "codeartifact.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "codeartifact.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "codeartifact.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "codeartifact.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "codeartifact.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "codeartifact.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "codeartifact.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "codeartifact.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "codeartifact.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "codeartifact.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "codeartifact", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "codeartifact.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "codeartifact.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "codeartifact.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "codeartifact.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "codeartifact.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "codeartifact", + regionHash, + partitionHash, + }); diff --git a/clients/client-codebuild/endpoints.ts b/clients/client-codebuild/endpoints.ts index 54f9923bc82f9..40238a943a041 100644 --- a/clients/client-codebuild/endpoints.ts +++ b/clients/client-codebuild/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "codebuild.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "codebuild.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "codebuild.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "codebuild.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "codebuild.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "codebuild-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "codebuild-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1-fips": { + hostname: "codebuild-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1-fips": { + hostname: "codebuild-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "codebuild-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "codebuild-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "codebuild.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "codebuild.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "codebuild.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "codebuild.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "codebuild.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "codebuild.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "codebuild.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "codebuild.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "codebuild.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "codebuild.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "codebuild.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "codebuild.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "codebuild.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "codebuild.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "codebuild.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "codebuild.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "codebuild.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "codebuild.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "codebuild.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "codebuild.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "codebuild-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "codebuild.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "codebuild-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "codebuild.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-east-1-fips": - regionInfo = { - hostname: "codebuild-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "codebuild.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "codebuild-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "codebuild.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "codebuild-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "codebuild.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "codebuild-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "codebuild", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "codebuild.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "codebuild.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "codebuild.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "codebuild.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-east-1-fips", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "codebuild.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "codebuild", + regionHash, + partitionHash, + }); diff --git a/clients/client-codecommit/endpoints.ts b/clients/client-codecommit/endpoints.ts index dacfa13c10bc0..507ccefceb7ff 100644 --- a/clients/client-codecommit/endpoints.ts +++ b/clients/client-codecommit/endpoints.ts @@ -1,235 +1,63 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "codecommit.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "codecommit.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "codecommit.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "codecommit.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "codecommit.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + fips: { + hostname: "codecommit-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "codecommit.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "codecommit.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "codecommit.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "codecommit.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "codecommit.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "codecommit.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "codecommit.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "codecommit.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "codecommit.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "codecommit.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "codecommit.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "codecommit.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "codecommit.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "codecommit.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "codecommit.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "codecommit.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips": - regionInfo = { - hostname: "codecommit-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "codecommit.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "codecommit.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "codecommit.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "codecommit.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "codecommit.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "codecommit.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "codecommit.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "codecommit.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "codecommit", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "codecommit.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "codecommit.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "codecommit.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "codecommit.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips", "us-gov-east-1", "us-gov-west-1"], + hostname: "codecommit.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "codecommit", + regionHash, + partitionHash, + }); diff --git a/clients/client-codedeploy/endpoints.ts b/clients/client-codedeploy/endpoints.ts index 0ce22f629a416..e83ac2d67a756 100644 --- a/clients/client-codedeploy/endpoints.ts +++ b/clients/client-codedeploy/endpoints.ts @@ -1,288 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "codedeploy.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "codedeploy.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "codedeploy.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "codedeploy.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "codedeploy.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "codedeploy-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "codedeploy-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1-fips": { + hostname: "codedeploy-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1-fips": { + hostname: "codedeploy-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "codedeploy-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "codedeploy-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "codedeploy.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "codedeploy.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "codedeploy.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "codedeploy.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "codedeploy.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "codedeploy.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "codedeploy.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "codedeploy.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "codedeploy.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "codedeploy.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "codedeploy.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "codedeploy.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "codedeploy.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "codedeploy.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "codedeploy.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "codedeploy.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "codedeploy.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "codedeploy.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "codedeploy.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "codedeploy.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "codedeploy-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "codedeploy.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "codedeploy-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "codedeploy.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-east-1-fips": - regionInfo = { - hostname: "codedeploy-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "codedeploy.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "codedeploy-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "codedeploy.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "codedeploy.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "codedeploy.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "codedeploy-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "codedeploy.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "codedeploy-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "codedeploy", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "codedeploy.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "codedeploy.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "codedeploy.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "codedeploy.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-east-1-fips", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "codedeploy.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "codedeploy", + regionHash, + partitionHash, + }); diff --git a/clients/client-codeguru-reviewer/endpoints.ts b/clients/client-codeguru-reviewer/endpoints.ts index 49ef902722ee4..24b7ac2019858 100644 --- a/clients/client-codeguru-reviewer/endpoints.ts +++ b/clients/client-codeguru-reviewer/endpoints.ts @@ -1,144 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "codeguru-reviewer.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "codeguru-reviewer.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "codeguru-reviewer.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "codeguru-reviewer.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "codeguru-reviewer.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "codeguru-reviewer.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "codeguru-reviewer.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "codeguru-reviewer.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "codeguru-reviewer.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "codeguru-reviewer.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "codeguru-reviewer.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "codeguru-reviewer.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "codeguru-reviewer.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "codeguru-reviewer.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "codeguru-reviewer.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "codeguru-reviewer", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "codeguru-reviewer.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "codeguru-reviewer.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "codeguru-reviewer.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "codeguru-reviewer.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "codeguru-reviewer.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "codeguru-reviewer", + regionHash, + partitionHash, + }); diff --git a/clients/client-codeguruprofiler/endpoints.ts b/clients/client-codeguruprofiler/endpoints.ts index bb43aa3794309..21c9b64221415 100644 --- a/clients/client-codeguruprofiler/endpoints.ts +++ b/clients/client-codeguruprofiler/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "codeguru-profiler.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "codeguru-profiler.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "codeguru-profiler.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "codeguru-profiler.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "codeguru-profiler.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "codeguru-profiler", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "codeguru-profiler.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "codeguru-profiler.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "codeguru-profiler.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "codeguru-profiler.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "codeguru-profiler.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "codeguru-profiler", + regionHash, + partitionHash, + }); diff --git a/clients/client-codepipeline/endpoints.ts b/clients/client-codepipeline/endpoints.ts index 0045e291ecd61..8003f51558ab0 100644 --- a/clients/client-codepipeline/endpoints.ts +++ b/clients/client-codepipeline/endpoints.ts @@ -1,240 +1,87 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "codepipeline.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "codepipeline.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "codepipeline.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "codepipeline.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "codepipeline.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "codepipeline-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "codepipeline-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "codepipeline-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-west-1": { + hostname: "codepipeline-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "codepipeline-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "codepipeline-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "codepipeline.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "codepipeline.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "codepipeline.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "codepipeline.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "codepipeline.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "codepipeline.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "codepipeline.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "codepipeline.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "codepipeline.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "codepipeline.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "codepipeline.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "codepipeline.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "codepipeline.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "codepipeline-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "codepipeline-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "codepipeline-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "codepipeline-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "codepipeline-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "codepipeline-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "codepipeline.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "codepipeline.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "codepipeline.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "codepipeline.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "codepipeline.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "codepipeline.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "codepipeline", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "codepipeline.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "codepipeline.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "codepipeline.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "codepipeline.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "codepipeline.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "codepipeline", + regionHash, + partitionHash, + }); diff --git a/clients/client-codestar-connections/endpoints.ts b/clients/client-codestar-connections/endpoints.ts index 33f0cad42744e..eb71954ee9109 100644 --- a/clients/client-codestar-connections/endpoints.ts +++ b/clients/client-codestar-connections/endpoints.ts @@ -1,180 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "codestar-connections.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "codestar-connections.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "codestar-connections.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "codestar-connections.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "codestar-connections.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "codestar-connections.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "codestar-connections.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "codestar-connections.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "codestar-connections.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "codestar-connections.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "codestar-connections.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "codestar-connections.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "codestar-connections.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "codestar-connections.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "codestar-connections.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "codestar-connections.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "codestar-connections.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "codestar-connections.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "codestar-connections.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "codestar-connections.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "codestar-connections.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "codestar-connections", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "codestar-connections.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "codestar-connections.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "codestar-connections.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "codestar-connections.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "codestar-connections.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "codestar-connections", + regionHash, + partitionHash, + }); diff --git a/clients/client-codestar-notifications/endpoints.ts b/clients/client-codestar-notifications/endpoints.ts index 4d001e7342de7..e75807f9c0277 100644 --- a/clients/client-codestar-notifications/endpoints.ts +++ b/clients/client-codestar-notifications/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "codestar-notifications.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "codestar-notifications.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "codestar-notifications.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "codestar-notifications.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "codestar-notifications.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "codestar-notifications", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "codestar-notifications.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "codestar-notifications.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "codestar-notifications.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "codestar-notifications.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "codestar-notifications.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "codestar-notifications", + regionHash, + partitionHash, + }); diff --git a/clients/client-codestar/endpoints.ts b/clients/client-codestar/endpoints.ts index 8526df3fd538e..bead567cfddb8 100644 --- a/clients/client-codestar/endpoints.ts +++ b/clients/client-codestar/endpoints.ts @@ -1,162 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "codestar.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "codestar.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "codestar.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "codestar.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "codestar.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "codestar.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "codestar.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "codestar.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "codestar.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "codestar.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "codestar.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "codestar.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "codestar.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "codestar.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "codestar.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "codestar.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "codestar.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "codestar.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "codestar", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "codestar.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "codestar.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "codestar.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "codestar.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "codestar.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "codestar", + regionHash, + partitionHash, + }); diff --git a/clients/client-cognito-identity-provider/endpoints.ts b/clients/client-cognito-identity-provider/endpoints.ts index ab0f291b12aaa..e7816ac0e7a96 100644 --- a/clients/client-cognito-identity-provider/endpoints.ts +++ b/clients/client-cognito-identity-provider/endpoints.ts @@ -1,227 +1,82 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "cognito-idp.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "cognito-idp.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "cognito-idp.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "cognito-idp.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "cognito-idp.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "cognito-idp-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "cognito-idp-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-west-1": { + hostname: "cognito-idp-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "cognito-idp-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "cognito-idp-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "cognito-idp.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "cognito-idp.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "cognito-idp.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "cognito-idp.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "cognito-idp.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "cognito-idp.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "cognito-idp.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "cognito-idp.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "cognito-idp.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "cognito-idp.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "cognito-idp.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "cognito-idp-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "cognito-idp-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "cognito-idp-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "cognito-idp-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "cognito-idp-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "cognito-idp.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "cognito-idp.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "cognito-idp.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "cognito-idp.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "cognito-idp.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "cognito-idp.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "cognito-idp.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "cognito-idp", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "cognito-idp.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "cognito-idp.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "cognito-idp.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "cognito-idp.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "cognito-idp.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "cognito-idp", + regionHash, + partitionHash, + }); diff --git a/clients/client-cognito-identity/endpoints.ts b/clients/client-cognito-identity/endpoints.ts index ffab7c889d21c..37e9ead79af88 100644 --- a/clients/client-cognito-identity/endpoints.ts +++ b/clients/client-cognito-identity/endpoints.ts @@ -1,226 +1,77 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "cognito-identity.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "cognito-identity.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "cognito-identity.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "cognito-identity.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "cognito-identity.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "cognito-identity-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "cognito-identity-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-west-1": { + hostname: "cognito-identity-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-2": { + hostname: "cognito-identity-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "cognito-identity.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "cognito-identity.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "cognito-identity.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "cognito-identity.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "cognito-identity.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "cognito-identity.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "cognito-identity.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "cognito-identity.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "cognito-identity.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "cognito-identity.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "cognito-identity.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "cognito-identity.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "cognito-identity-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "cognito-identity-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "cognito-identity-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "cognito-identity-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "cognito-identity.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "cognito-identity.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "cognito-identity.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "cognito-identity.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "cognito-identity.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "cognito-identity.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "cognito-identity.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "cognito-identity", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "cognito-identity.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "cognito-identity.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "cognito-identity.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "cognito-identity.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "cognito-identity.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "cognito-identity", + regionHash, + partitionHash, + }); diff --git a/clients/client-cognito-sync/endpoints.ts b/clients/client-cognito-sync/endpoints.ts index e18ab97c3008b..408a7b8932ec7 100644 --- a/clients/client-cognito-sync/endpoints.ts +++ b/clients/client-cognito-sync/endpoints.ts @@ -1,150 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "cognito-sync.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "cognito-sync.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "cognito-sync.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "cognito-sync.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "cognito-sync.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "cognito-sync.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "cognito-sync.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "cognito-sync.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "cognito-sync.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "cognito-sync.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "cognito-sync.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "cognito-sync.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "cognito-sync.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "cognito-sync.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "cognito-sync.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "cognito-sync.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "cognito-sync", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "cognito-sync.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "cognito-sync.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "cognito-sync.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "cognito-sync.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "cognito-sync.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "cognito-sync", + regionHash, + partitionHash, + }); diff --git a/clients/client-comprehend/endpoints.ts b/clients/client-comprehend/endpoints.ts index 8ef56155a81e2..fb45a69432953 100644 --- a/clients/client-comprehend/endpoints.ts +++ b/clients/client-comprehend/endpoints.ts @@ -1,196 +1,77 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "comprehend.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "comprehend.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "comprehend.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "comprehend.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "comprehend.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "comprehend-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "comprehend-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-west-1": { + hostname: "comprehend-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-2": { + hostname: "comprehend-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "comprehend.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "comprehend.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "comprehend.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "comprehend.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "comprehend.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "comprehend.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "comprehend.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "comprehend.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "comprehend.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "comprehend-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "comprehend-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "comprehend-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "comprehend-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "comprehend.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "comprehend.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "comprehend.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "comprehend.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "comprehend.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "comprehend", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "comprehend.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "comprehend.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "comprehend.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "comprehend.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "comprehend.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "comprehend", + regionHash, + partitionHash, + }); diff --git a/clients/client-comprehendmedical/endpoints.ts b/clients/client-comprehendmedical/endpoints.ts index 3004a228160be..6796f315e4bd2 100644 --- a/clients/client-comprehendmedical/endpoints.ts +++ b/clients/client-comprehendmedical/endpoints.ts @@ -1,160 +1,77 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "comprehendmedical.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "comprehendmedical.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "comprehendmedical.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "comprehendmedical.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "comprehendmedical.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "comprehendmedical-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "comprehendmedical-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-west-1": { + hostname: "comprehendmedical-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-2": { + hostname: "comprehendmedical-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-southeast-2": - regionInfo = { - hostname: "comprehendmedical.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "comprehendmedical.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "comprehendmedical.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "comprehendmedical.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "comprehendmedical-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "comprehendmedical-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "comprehendmedical-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "comprehendmedical-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "comprehendmedical.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "comprehendmedical.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "comprehendmedical.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "comprehendmedical.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "comprehendmedical", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "comprehendmedical.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "comprehendmedical.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "comprehendmedical.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "comprehendmedical.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "comprehendmedical.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "comprehendmedical", + regionHash, + partitionHash, + }); diff --git a/clients/client-compute-optimizer/endpoints.ts b/clients/client-compute-optimizer/endpoints.ts index 0e1c939022888..c0f8780317266 100644 --- a/clients/client-compute-optimizer/endpoints.ts +++ b/clients/client-compute-optimizer/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "compute-optimizer.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "compute-optimizer.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "compute-optimizer.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "compute-optimizer.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "compute-optimizer.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "compute-optimizer", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "compute-optimizer.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "compute-optimizer.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "compute-optimizer.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "compute-optimizer.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "compute-optimizer.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "compute-optimizer", + regionHash, + partitionHash, + }); diff --git a/clients/client-config-service/endpoints.ts b/clients/client-config-service/endpoints.ts index a3358f6af6628..1c97dd405d0b1 100644 --- a/clients/client-config-service/endpoints.ts +++ b/clients/client-config-service/endpoints.ts @@ -1,288 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "config.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "config.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "config.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "config.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "config.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "config-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "config-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "config.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "config.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "config-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "config-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "config.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "config.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "config.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "config.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "config.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "config.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "config.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "config.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "config.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "config.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "config.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "config.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "config.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "config.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "config.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "config.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "config.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "config-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "config-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "config.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "config.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "config-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "config-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "config.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "config.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "config.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "config.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "config.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "config.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "config.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "config.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "config.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "config.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "config", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "config.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "config.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "config.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "config.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "config.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "config", + regionHash, + partitionHash, + }); diff --git a/clients/client-connect-contact-lens/endpoints.ts b/clients/client-connect-contact-lens/endpoints.ts index a0ada88f165f4..a60cf6b47143d 100644 --- a/clients/client-connect-contact-lens/endpoints.ts +++ b/clients/client-connect-contact-lens/endpoints.ts @@ -1,126 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "contact-lens.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "contact-lens.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "contact-lens.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "contact-lens.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "contact-lens.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "contact-lens.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "contact-lens.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "contact-lens.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "contact-lens.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "contact-lens.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "contact-lens.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "contact-lens.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "connect", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "contact-lens.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "contact-lens.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "contact-lens.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "contact-lens.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "contact-lens.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "connect", + regionHash, + partitionHash, + }); diff --git a/clients/client-connect/endpoints.ts b/clients/client-connect/endpoints.ts index 88ff6eb543ebd..05991eface638 100644 --- a/clients/client-connect/endpoints.ts +++ b/clients/client-connect/endpoints.ts @@ -1,138 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "connect.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "connect.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "connect.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "connect.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "connect.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "connect.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "connect.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "connect.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "connect.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "connect.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "connect.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "connect.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "connect.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "connect.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "connect", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "connect.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "connect.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "connect.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "connect.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "connect.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "connect", + regionHash, + partitionHash, + }); diff --git a/clients/client-connectparticipant/endpoints.ts b/clients/client-connectparticipant/endpoints.ts index 8cfc4ae2d562b..1b538b897e454 100644 --- a/clients/client-connectparticipant/endpoints.ts +++ b/clients/client-connectparticipant/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "participant.connect.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "participant.connect.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "participant.connect.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "participant.connect.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "participant.connect.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "execute-api", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "participant.connect.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "participant.connect.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "participant.connect.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "participant.connect.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "participant.connect.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "execute-api", + regionHash, + partitionHash, + }); diff --git a/clients/client-cost-and-usage-report-service/endpoints.ts b/clients/client-cost-and-usage-report-service/endpoints.ts index 56cdaade5ddc5..2e669c226813b 100644 --- a/clients/client-cost-and-usage-report-service/endpoints.ts +++ b/clients/client-cost-and-usage-report-service/endpoints.ts @@ -1,96 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "cur.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "cur.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "cur.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "cur.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "cur.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "cn-northwest-1": - regionInfo = { - hostname: "cur.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "cur.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "cur", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "cur.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "cur.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "cur.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "cur.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "cur.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "cur", + regionHash, + partitionHash, + }); diff --git a/clients/client-cost-explorer/endpoints.ts b/clients/client-cost-explorer/endpoints.ts index a648b3d4c94cf..b52440ecba9ce 100644 --- a/clients/client-cost-explorer/endpoints.ts +++ b/clients/client-cost-explorer/endpoints.ts @@ -1,89 +1,67 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "ce.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "ce.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "ce.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "ce.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "ce.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-cn-global": { + hostname: "ce.cn-northwest-1.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "aws-global": { + hostname: "ce.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "aws-cn-global": - regionInfo = { - hostname: "ce.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "aws-global": - regionInfo = { - hostname: "ce.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-global"); - } - if (AWS_CN_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-cn-global"); - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - return defaultRegionInfoProvider("aws-global"); - } - } - return Promise.resolve({ signingService: "ce", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + endpoint: "aws-global", + }, + "aws-cn": { + regions: ["aws-cn-global", "cn-north-1", "cn-northwest-1"], + endpoint: "aws-cn-global", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "ce.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "ce.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "ce.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ce", + regionHash, + partitionHash, + }); diff --git a/clients/client-customer-profiles/endpoints.ts b/clients/client-customer-profiles/endpoints.ts index 87372979cc2b5..29807760cff1d 100644 --- a/clients/client-customer-profiles/endpoints.ts +++ b/clients/client-customer-profiles/endpoints.ts @@ -1,132 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "profile.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "profile.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "profile.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "profile.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "profile.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "profile.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "profile.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "profile.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "profile.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "profile.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "profile.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "profile.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "profile.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "profile", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "profile.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "profile.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "profile.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "profile.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "profile.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "profile", + regionHash, + partitionHash, + }); diff --git a/clients/client-data-pipeline/endpoints.ts b/clients/client-data-pipeline/endpoints.ts index 130204050798a..55ec083a3c0f4 100644 --- a/clients/client-data-pipeline/endpoints.ts +++ b/clients/client-data-pipeline/endpoints.ts @@ -1,120 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "datapipeline.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "datapipeline.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "datapipeline.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "datapipeline.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "datapipeline.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "datapipeline.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "datapipeline.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "datapipeline.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "datapipeline.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "datapipeline.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "datapipeline.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "datapipeline", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "datapipeline.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "datapipeline.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "datapipeline.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "datapipeline.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "datapipeline.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "datapipeline", + regionHash, + partitionHash, + }); diff --git a/clients/client-database-migration-service/endpoints.ts b/clients/client-database-migration-service/endpoints.ts index 67d937fa2c57c..e82f9cdb99fd3 100644 --- a/clients/client-database-migration-service/endpoints.ts +++ b/clients/client-database-migration-service/endpoints.ts @@ -1,253 +1,63 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "dms.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "dms.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "dms.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "dms.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "dms.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "dms-fips": { + hostname: "dms.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "dms.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "dms.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "dms.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "dms.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "dms.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "dms.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "dms.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "dms.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "dms.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "dms.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "dms.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "dms-fips": - regionInfo = { - hostname: "dms.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "dms.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "dms.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "dms.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "dms.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "dms.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "dms.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "dms.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "dms.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "dms.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "dms.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "dms.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "dms.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "dms.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "dms.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "dms.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "dms.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "dms", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "dms-fips", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "dms.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "dms.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["dms-fips", "us-iso-east-1"], + hostname: "dms.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["dms-fips", "us-isob-east-1"], + hostname: "dms.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["dms-fips", "us-gov-east-1", "us-gov-west-1"], + hostname: "dms.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "dms", + regionHash, + partitionHash, + }); diff --git a/clients/client-databrew/endpoints.ts b/clients/client-databrew/endpoints.ts index fe06f9b0f5bd0..1ec0cbea39382 100644 --- a/clients/client-databrew/endpoints.ts +++ b/clients/client-databrew/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "databrew.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "databrew.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "databrew.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "databrew.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "databrew.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "databrew", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "databrew.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "databrew.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "databrew.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "databrew.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "databrew.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "databrew", + regionHash, + partitionHash, + }); diff --git a/clients/client-dataexchange/endpoints.ts b/clients/client-dataexchange/endpoints.ts index f1200b993f549..8907c51b46716 100644 --- a/clients/client-dataexchange/endpoints.ts +++ b/clients/client-dataexchange/endpoints.ts @@ -1,150 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "dataexchange.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "dataexchange.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "dataexchange.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "dataexchange.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "dataexchange.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "dataexchange.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "dataexchange.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "dataexchange.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "dataexchange.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "dataexchange.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "dataexchange.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "dataexchange.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "dataexchange.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "dataexchange.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "dataexchange.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "dataexchange.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "dataexchange", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "dataexchange.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "dataexchange.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "dataexchange.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "dataexchange.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "dataexchange.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "dataexchange", + regionHash, + partitionHash, + }); diff --git a/clients/client-datasync/endpoints.ts b/clients/client-datasync/endpoints.ts index 15e0f07f84a54..5215a3d55df9c 100644 --- a/clients/client-datasync/endpoints.ts +++ b/clients/client-datasync/endpoints.ts @@ -1,271 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "datasync.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "datasync.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "datasync.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "datasync.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "datasync.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "datasync-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "datasync-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "datasync-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "datasync-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "datasync-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "datasync-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "datasync-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "datasync.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "datasync.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "datasync.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "datasync.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "datasync.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "datasync.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "datasync.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "datasync.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "datasync.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "datasync.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "datasync.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "datasync.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "datasync.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "datasync.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "datasync.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "datasync-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "datasync-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "datasync-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "datasync-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "datasync-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "datasync-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "datasync-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "datasync.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "datasync.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "datasync.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "datasync.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "datasync.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "datasync.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "datasync.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "datasync.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "datasync", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "datasync.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "datasync.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "datasync.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "datasync.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "datasync.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "datasync", + regionHash, + partitionHash, + }); diff --git a/clients/client-dax/endpoints.ts b/clients/client-dax/endpoints.ts index cb4a880b8ac37..6331164dda904 100644 --- a/clients/client-dax/endpoints.ts +++ b/clients/client-dax/endpoints.ts @@ -1,174 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "dax.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "dax.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "dax.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "dax.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "dax.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "dax.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "dax.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "dax.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "dax.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "dax.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "dax.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "dax.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "dax.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "dax.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "dax.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "dax.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "dax.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "dax.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "dax.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "dax.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "dax", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "dax.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "dax.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "dax.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "dax.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "dax.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "dax", + regionHash, + partitionHash, + }); diff --git a/clients/client-detective/endpoints.ts b/clients/client-detective/endpoints.ts index abadb47e02389..1d28ca3b4496d 100644 --- a/clients/client-detective/endpoints.ts +++ b/clients/client-detective/endpoints.ts @@ -1,258 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "api.detective.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "api.detective.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "api.detective.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "api.detective.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "api.detective.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "api.detective-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "api.detective-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1-fips": { + hostname: "api.detective-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1-fips": { + hostname: "api.detective-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "api.detective-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "api.detective-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "api.detective.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "api.detective.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "api.detective.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "api.detective.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "api.detective.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "api.detective.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "api.detective.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "api.detective.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "api.detective.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "api.detective.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "api.detective.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "api.detective.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "api.detective.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "api.detective.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "api.detective.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "api.detective.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "api.detective.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "api.detective-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "api.detective.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "api.detective-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "api.detective.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-east-1-fips": - regionInfo = { - hostname: "api.detective-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "api.detective.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "api.detective-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "api.detective.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "api.detective-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "api.detective.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "api.detective-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "detective", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "api.detective.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "api.detective.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "api.detective.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "api.detective.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-east-1-fips", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "api.detective.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "detective", + regionHash, + partitionHash, + }); diff --git a/clients/client-device-farm/endpoints.ts b/clients/client-device-farm/endpoints.ts index 59059128b31ae..e54ec707a713b 100644 --- a/clients/client-device-farm/endpoints.ts +++ b/clients/client-device-farm/endpoints.ts @@ -1,90 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "devicefarm.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "devicefarm.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "devicefarm.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "devicefarm.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "devicefarm.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "us-west-2": - regionInfo = { - hostname: "devicefarm.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "devicefarm", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "devicefarm.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "devicefarm.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "devicefarm.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "devicefarm.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "devicefarm.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "devicefarm", + regionHash, + partitionHash, + }); diff --git a/clients/client-devops-guru/endpoints.ts b/clients/client-devops-guru/endpoints.ts index e7c911c826ddd..081b9992f1088 100644 --- a/clients/client-devops-guru/endpoints.ts +++ b/clients/client-devops-guru/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "devops-guru.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "devops-guru.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "devops-guru.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "devops-guru.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "devops-guru.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "devops-guru", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "devops-guru.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "devops-guru.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "devops-guru.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "devops-guru.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "devops-guru.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "devops-guru", + regionHash, + partitionHash, + }); diff --git a/clients/client-direct-connect/endpoints.ts b/clients/client-direct-connect/endpoints.ts index d43177b9ac5c1..8fda5e0a7b81a 100644 --- a/clients/client-direct-connect/endpoints.ts +++ b/clients/client-direct-connect/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "directconnect.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "directconnect.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "directconnect.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "directconnect.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "directconnect.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "directconnect-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "directconnect-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "directconnect-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "directconnect-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "directconnect.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "directconnect.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "directconnect.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "directconnect.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "directconnect.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "directconnect.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "directconnect.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "directconnect.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "directconnect.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "directconnect.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "directconnect.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "directconnect.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "directconnect.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "directconnect.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "directconnect.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "directconnect.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "directconnect.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "directconnect.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "directconnect.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "directconnect-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "directconnect-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "directconnect-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "directconnect-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "directconnect.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "directconnect.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "directconnect.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "directconnect.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "directconnect.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "directconnect.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "directconnect.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "directconnect.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "directconnect.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "directconnect.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "directconnect", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "directconnect.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "directconnect.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "directconnect.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "directconnect.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "directconnect.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "directconnect", + regionHash, + partitionHash, + }); diff --git a/clients/client-directory-service/endpoints.ts b/clients/client-directory-service/endpoints.ts index c58e1221d289e..23c5837748af8 100644 --- a/clients/client-directory-service/endpoints.ts +++ b/clients/client-directory-service/endpoints.ts @@ -1,295 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "ds.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "ds.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "ds.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "ds.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "ds.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "ds-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "ds-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "ds-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "ds-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "ds-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "ds-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "ds-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "ds.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "ds.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "ds.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "ds.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "ds.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "ds.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "ds.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "ds.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "ds.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "ds.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "ds.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "ds.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "ds.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "ds.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "ds.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "ds.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "ds.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "ds-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "ds-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "ds-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "ds-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "ds-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "ds-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "ds-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "ds.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "ds.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "ds.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "ds.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "ds.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "ds.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "ds.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "ds.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "ds.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "ds.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ds", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "ds.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "ds.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "ds.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "ds.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "ds.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ds", + regionHash, + partitionHash, + }); diff --git a/clients/client-dlm/endpoints.ts b/clients/client-dlm/endpoints.ts index abce926144812..e4ed8abef39f8 100644 --- a/clients/client-dlm/endpoints.ts +++ b/clients/client-dlm/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "dlm.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "dlm.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "dlm.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "dlm.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "dlm.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "dlm", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "dlm.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "dlm.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "dlm.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "dlm.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "dlm.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "dlm", + regionHash, + partitionHash, + }); diff --git a/clients/client-docdb/endpoints.ts b/clients/client-docdb/endpoints.ts index 0b266f527507b..c6b4b1921027e 100644 --- a/clients/client-docdb/endpoints.ts +++ b/clients/client-docdb/endpoints.ts @@ -1,295 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "rds.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "rds.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "rds.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "rds.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "rds.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "rds-fips.ca-central-1": { + hostname: "rds-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "rds-fips.us-east-1": { + hostname: "rds-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "rds-fips.us-east-2": { + hostname: "rds-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "rds-fips.us-west-1": { + hostname: "rds-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "rds-fips.us-west-2": { + hostname: "rds-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "rds.us-gov-east-1": { + hostname: "rds.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "rds.us-gov-west-1": { + hostname: "rds.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "rds.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "rds.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "rds.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "rds.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "rds.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "rds.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "rds.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "rds.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "rds.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "rds.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "rds.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "rds.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "rds.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "rds.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "rds.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "rds.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "rds.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "rds.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "rds-fips.ca-central-1": - regionInfo = { - hostname: "rds-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "rds-fips.us-east-1": - regionInfo = { - hostname: "rds-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "rds-fips.us-east-2": - regionInfo = { - hostname: "rds-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "rds-fips.us-west-1": - regionInfo = { - hostname: "rds-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "rds-fips.us-west-2": - regionInfo = { - hostname: "rds-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "rds.us-gov-east-1": - regionInfo = { - hostname: "rds.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "rds.us-gov-west-1": - regionInfo = { - hostname: "rds.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "rds.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "rds.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "rds.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "rds.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "rds.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "rds.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "rds.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "rds.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "rds.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "rds", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "rds-fips.ca-central-1", + "rds-fips.us-east-1", + "rds-fips.us-east-2", + "rds-fips.us-west-1", + "rds-fips.us-west-2", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "rds.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "rds.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "rds.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "rds.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["rds.us-gov-east-1", "rds.us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "rds.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "rds", + regionHash, + partitionHash, + }); diff --git a/clients/client-dynamodb-streams/endpoints.ts b/clients/client-dynamodb-streams/endpoints.ts index 9a89ad9c19353..dc5f653a3d592 100644 --- a/clients/client-dynamodb-streams/endpoints.ts +++ b/clients/client-dynamodb-streams/endpoints.ts @@ -1,307 +1,96 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "streams.dynamodb.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "streams.dynamodb.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "streams.dynamodb.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "streams.dynamodb.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "streams.dynamodb.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "ca-central-1-fips": { + hostname: "dynamodb-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + local: { + hostname: "localhost:8000", + signingRegion: "us-east-1", + }, + "us-east-1-fips": { + hostname: "dynamodb-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "dynamodb-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1-fips": { + hostname: "dynamodb.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1-fips": { + hostname: "dynamodb.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "dynamodb-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "dynamodb-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "streams.dynamodb.ap-northeast-1.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "streams.dynamodb.ap-northeast-2.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "streams.dynamodb.ap-south-1.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "streams.dynamodb.ap-southeast-1.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "streams.dynamodb.ap-southeast-2.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "streams.dynamodb.ca-central-1.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "ca-central-1-fips": - regionInfo = { - hostname: "dynamodb-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "streams.dynamodb.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - signingService: "dynamodb", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "streams.dynamodb.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingService: "dynamodb", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "streams.dynamodb.eu-central-1.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "streams.dynamodb.eu-north-1.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "streams.dynamodb.eu-west-1.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "streams.dynamodb.eu-west-2.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "streams.dynamodb.eu-west-3.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "local": - regionInfo = { - hostname: "localhost:8000", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "streams.dynamodb.me-south-1.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "streams.dynamodb.sa-east-1.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "streams.dynamodb.us-east-1.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "dynamodb-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "streams.dynamodb.us-east-2.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "dynamodb-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "streams.dynamodb.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "dynamodb", - }; - break; - case "us-gov-east-1-fips": - regionInfo = { - hostname: "dynamodb.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "streams.dynamodb.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "dynamodb", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "dynamodb.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "streams.dynamodb.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - signingService: "dynamodb", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "streams.dynamodb.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - signingService: "dynamodb", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "streams.dynamodb.us-west-1.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "dynamodb-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "streams.dynamodb.us-west-2.amazonaws.com", - partition: "aws", - signingService: "dynamodb", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "dynamodb-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "dynamodb", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - signingService: "dynamodb", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - signingService: "dynamodb", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - signingService: "dynamodb", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - signingService: "dynamodb", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "dynamodb", - }; - } - } - return Promise.resolve({ signingService: "dynamodb", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "ca-central-1-fips", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "local", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "streams.dynamodb.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "streams.dynamodb.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "streams.dynamodb.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "streams.dynamodb.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-east-1-fips", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "streams.dynamodb.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "dynamodb", + regionHash, + partitionHash, + }); diff --git a/clients/client-dynamodb/endpoints.ts b/clients/client-dynamodb/endpoints.ts index 4aff44997b80f..b75bce97146f1 100644 --- a/clients/client-dynamodb/endpoints.ts +++ b/clients/client-dynamodb/endpoints.ts @@ -1,302 +1,96 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "dynamodb.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "dynamodb.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "dynamodb.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "dynamodb.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "dynamodb.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "ca-central-1-fips": { + hostname: "dynamodb-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + local: { + hostname: "localhost:8000", + signingRegion: "us-east-1", + }, + "us-east-1-fips": { + hostname: "dynamodb-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "dynamodb-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1-fips": { + hostname: "dynamodb.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1-fips": { + hostname: "dynamodb.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "dynamodb-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "dynamodb-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "dynamodb.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "dynamodb.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "dynamodb.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "dynamodb.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "dynamodb.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "dynamodb.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "dynamodb.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "dynamodb.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "dynamodb.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1-fips": - regionInfo = { - hostname: "dynamodb-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "dynamodb.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "dynamodb.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "dynamodb.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "dynamodb.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "dynamodb.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "dynamodb.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "dynamodb.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "dynamodb.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "local": - regionInfo = { - hostname: "localhost:8000", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "dynamodb.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "dynamodb.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "dynamodb.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "dynamodb-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "dynamodb.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "dynamodb-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "dynamodb.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-east-1-fips": - regionInfo = { - hostname: "dynamodb.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "dynamodb.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "dynamodb.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "dynamodb.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "dynamodb.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "dynamodb.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "dynamodb-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "dynamodb.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "dynamodb-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "dynamodb", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "ca-central-1-fips", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "local", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "dynamodb.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "dynamodb.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "dynamodb.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "dynamodb.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-east-1-fips", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "dynamodb.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "dynamodb", + regionHash, + partitionHash, + }); diff --git a/clients/client-ebs/endpoints.ts b/clients/client-ebs/endpoints.ts index 03a65289042d0..c904e9d73c308 100644 --- a/clients/client-ebs/endpoints.ts +++ b/clients/client-ebs/endpoints.ts @@ -1,269 +1,83 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "ebs.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "ebs.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "ebs.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "ebs.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "ebs.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "ebs-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "ebs-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "ebs-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "ebs-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "ebs-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "ebs.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "ebs.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "ebs.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "ebs.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "ebs.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "ebs.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "ebs.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "ebs.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "ebs.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "ebs.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "ebs.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "ebs.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "ebs.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "ebs.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "ebs.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "ebs.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "ebs.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "ebs-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "ebs-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "ebs-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "ebs-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "ebs-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "ebs.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "ebs.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "ebs.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "ebs.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "ebs.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "ebs.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "ebs.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "ebs.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ebs", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "ebs.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "ebs.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "ebs.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "ebs.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "ebs.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ebs", + regionHash, + partitionHash, + }); diff --git a/clients/client-ec2-instance-connect/endpoints.ts b/clients/client-ec2-instance-connect/endpoints.ts index 00f11c5f41ae3..82283705d3246 100644 --- a/clients/client-ec2-instance-connect/endpoints.ts +++ b/clients/client-ec2-instance-connect/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "ec2-instance-connect.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "ec2-instance-connect.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "ec2-instance-connect.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "ec2-instance-connect.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "ec2-instance-connect.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ec2-instance-connect", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "ec2-instance-connect.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "ec2-instance-connect.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "ec2-instance-connect.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "ec2-instance-connect.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "ec2-instance-connect.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ec2-instance-connect", + regionHash, + partitionHash, + }); diff --git a/clients/client-ec2/endpoints.ts b/clients/client-ec2/endpoints.ts index 422341a445a2a..7c0003f32e35f 100644 --- a/clients/client-ec2/endpoints.ts +++ b/clients/client-ec2/endpoints.ts @@ -1,283 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "ec2.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "ec2.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "ec2.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "ec2.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "ec2.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "ec2-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "ec2-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "ec2-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "ec2-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "ec2-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "ec2.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "ec2.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "ec2.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "ec2.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "ec2.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "ec2.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "ec2.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "ec2.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "ec2.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "ec2.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "ec2.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "ec2.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "ec2.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "ec2.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "ec2.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "ec2.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "ec2.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "ec2.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "ec2.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "ec2-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "ec2-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "ec2-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "ec2-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "ec2-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "ec2.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "ec2.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "ec2.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "ec2.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "ec2.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "ec2.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "ec2.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "ec2.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "ec2.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "ec2.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ec2", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "ec2.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "ec2.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "ec2.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "ec2.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "ec2.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ec2", + regionHash, + partitionHash, + }); diff --git a/clients/client-ecr-public/endpoints.ts b/clients/client-ecr-public/endpoints.ts index 14d727ad2c840..0a1f17bc1fb77 100644 --- a/clients/client-ecr-public/endpoints.ts +++ b/clients/client-ecr-public/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "api.ecr-public.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "api.ecr-public.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "api.ecr-public.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "api.ecr-public.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "api.ecr-public.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ecr-public", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "api.ecr-public.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "api.ecr-public.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "api.ecr-public.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "api.ecr-public.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "api.ecr-public.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ecr-public", + regionHash, + partitionHash, + }); diff --git a/clients/client-ecr/endpoints.ts b/clients/client-ecr/endpoints.ts index 9afff8500b90e..b343619d5c73f 100644 --- a/clients/client-ecr/endpoints.ts +++ b/clients/client-ecr/endpoints.ts @@ -1,357 +1,229 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "api.ecr.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "api.ecr.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "api.ecr.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "api.ecr.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "api.ecr.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "af-south-1": { + hostname: "api.ecr.af-south-1.amazonaws.com", + signingRegion: "af-south-1", + }, + "ap-east-1": { + hostname: "api.ecr.ap-east-1.amazonaws.com", + signingRegion: "ap-east-1", + }, + "ap-northeast-1": { + hostname: "api.ecr.ap-northeast-1.amazonaws.com", + signingRegion: "ap-northeast-1", + }, + "ap-northeast-2": { + hostname: "api.ecr.ap-northeast-2.amazonaws.com", + signingRegion: "ap-northeast-2", + }, + "ap-northeast-3": { + hostname: "api.ecr.ap-northeast-3.amazonaws.com", + signingRegion: "ap-northeast-3", + }, + "ap-south-1": { + hostname: "api.ecr.ap-south-1.amazonaws.com", + signingRegion: "ap-south-1", + }, + "ap-southeast-1": { + hostname: "api.ecr.ap-southeast-1.amazonaws.com", + signingRegion: "ap-southeast-1", + }, + "ap-southeast-2": { + hostname: "api.ecr.ap-southeast-2.amazonaws.com", + signingRegion: "ap-southeast-2", + }, + "ca-central-1": { + hostname: "api.ecr.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "cn-north-1": { + hostname: "api.ecr.cn-north-1.amazonaws.com.cn", + signingRegion: "cn-north-1", + }, + "cn-northwest-1": { + hostname: "api.ecr.cn-northwest-1.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "eu-central-1": { + hostname: "api.ecr.eu-central-1.amazonaws.com", + signingRegion: "eu-central-1", + }, + "eu-north-1": { + hostname: "api.ecr.eu-north-1.amazonaws.com", + signingRegion: "eu-north-1", + }, + "eu-south-1": { + hostname: "api.ecr.eu-south-1.amazonaws.com", + signingRegion: "eu-south-1", + }, + "eu-west-1": { + hostname: "api.ecr.eu-west-1.amazonaws.com", + signingRegion: "eu-west-1", + }, + "eu-west-2": { + hostname: "api.ecr.eu-west-2.amazonaws.com", + signingRegion: "eu-west-2", + }, + "eu-west-3": { + hostname: "api.ecr.eu-west-3.amazonaws.com", + signingRegion: "eu-west-3", + }, + "fips-dkr-us-east-1": { + hostname: "ecr-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-dkr-us-east-2": { + hostname: "ecr-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-dkr-us-gov-east-1": { + hostname: "ecr-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-dkr-us-gov-west-1": { + hostname: "ecr-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-dkr-us-west-1": { + hostname: "ecr-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-dkr-us-west-2": { + hostname: "ecr-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "fips-us-east-1": { + hostname: "ecr-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "ecr-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "ecr-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "ecr-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "ecr-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "ecr-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "me-south-1": { + hostname: "api.ecr.me-south-1.amazonaws.com", + signingRegion: "me-south-1", + }, + "sa-east-1": { + hostname: "api.ecr.sa-east-1.amazonaws.com", + signingRegion: "sa-east-1", + }, + "us-east-1": { + hostname: "api.ecr.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2": { + hostname: "api.ecr.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1": { + hostname: "api.ecr.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "api.ecr.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-iso-east-1": { + hostname: "api.ecr.us-iso-east-1.c2s.ic.gov", + signingRegion: "us-iso-east-1", + }, + "us-isob-east-1": { + hostname: "api.ecr.us-isob-east-1.sc2s.sgov.gov", + signingRegion: "us-isob-east-1", + }, + "us-west-1": { + hostname: "api.ecr.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2": { + hostname: "api.ecr.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "api.ecr.af-south-1.amazonaws.com", - partition: "aws", - signingRegion: "af-south-1", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "api.ecr.ap-east-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-east-1", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "api.ecr.ap-northeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-1", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "api.ecr.ap-northeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-2", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "api.ecr.ap-northeast-3.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-3", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "api.ecr.ap-south-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-south-1", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "api.ecr.ap-southeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-1", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "api.ecr.ap-southeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-2", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "api.ecr.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "api.ecr.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-north-1", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "api.ecr.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "api.ecr.eu-central-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-central-1", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "api.ecr.eu-north-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-north-1", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "api.ecr.eu-south-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-south-1", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "api.ecr.eu-west-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-1", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "api.ecr.eu-west-2.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-2", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "api.ecr.eu-west-3.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-3", - }; - break; - case "fips-dkr-us-east-1": - regionInfo = { - hostname: "ecr-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-dkr-us-east-2": - regionInfo = { - hostname: "ecr-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-dkr-us-gov-east-1": - regionInfo = { - hostname: "ecr-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-dkr-us-gov-west-1": - regionInfo = { - hostname: "ecr-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-dkr-us-west-1": - regionInfo = { - hostname: "ecr-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-dkr-us-west-2": - regionInfo = { - hostname: "ecr-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "ecr-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "ecr-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "ecr-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "ecr-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "ecr-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "ecr-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "api.ecr.me-south-1.amazonaws.com", - partition: "aws", - signingRegion: "me-south-1", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "api.ecr.sa-east-1.amazonaws.com", - partition: "aws", - signingRegion: "sa-east-1", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "api.ecr.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "api.ecr.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "api.ecr.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "api.ecr.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "api.ecr.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - signingRegion: "us-iso-east-1", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "api.ecr.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - signingRegion: "us-isob-east-1", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "api.ecr.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "api.ecr.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ecr", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-dkr-us-east-1", + "fips-dkr-us-east-2", + "fips-dkr-us-west-1", + "fips-dkr-us-west-2", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "api.ecr.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "api.ecr.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "api.ecr.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "api.ecr.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: [ + "fips-dkr-us-gov-east-1", + "fips-dkr-us-gov-west-1", + "fips-us-gov-east-1", + "fips-us-gov-west-1", + "us-gov-east-1", + "us-gov-west-1", + ], + hostname: "api.ecr.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ecr", + regionHash, + partitionHash, + }); diff --git a/clients/client-ecs/endpoints.ts b/clients/client-ecs/endpoints.ts index 39b75ba892f30..b684b6993950b 100644 --- a/clients/client-ecs/endpoints.ts +++ b/clients/client-ecs/endpoints.ts @@ -1,288 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "ecs.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "ecs.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "ecs.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "ecs.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "ecs.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "ecs-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "ecs-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "ecs-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "ecs-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "ecs-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "ecs-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "ecs.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "ecs.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "ecs.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "ecs.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "ecs.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "ecs.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "ecs.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "ecs.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "ecs.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "ecs.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "ecs.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "ecs.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "ecs.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "ecs.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "ecs.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "ecs.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "ecs.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "ecs-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "ecs-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "ecs-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "ecs-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "ecs-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "ecs-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "ecs.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "ecs.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "ecs.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "ecs.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "ecs.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "ecs.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "ecs.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "ecs.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "ecs.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "ecs.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ecs", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "ecs.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "ecs.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "ecs.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "ecs.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "ecs.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ecs", + regionHash, + partitionHash, + }); diff --git a/clients/client-efs/endpoints.ts b/clients/client-efs/endpoints.ts index 3caee3563a809..20e4b87f9190e 100644 --- a/clients/client-efs/endpoints.ts +++ b/clients/client-efs/endpoints.ts @@ -1,422 +1,183 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "elasticfilesystem.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "elasticfilesystem.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "elasticfilesystem.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "elasticfilesystem.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "elasticfilesystem.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-af-south-1": { + hostname: "elasticfilesystem-fips.af-south-1.amazonaws.com", + signingRegion: "af-south-1", + }, + "fips-ap-east-1": { + hostname: "elasticfilesystem-fips.ap-east-1.amazonaws.com", + signingRegion: "ap-east-1", + }, + "fips-ap-northeast-1": { + hostname: "elasticfilesystem-fips.ap-northeast-1.amazonaws.com", + signingRegion: "ap-northeast-1", + }, + "fips-ap-northeast-2": { + hostname: "elasticfilesystem-fips.ap-northeast-2.amazonaws.com", + signingRegion: "ap-northeast-2", + }, + "fips-ap-northeast-3": { + hostname: "elasticfilesystem-fips.ap-northeast-3.amazonaws.com", + signingRegion: "ap-northeast-3", + }, + "fips-ap-south-1": { + hostname: "elasticfilesystem-fips.ap-south-1.amazonaws.com", + signingRegion: "ap-south-1", + }, + "fips-ap-southeast-1": { + hostname: "elasticfilesystem-fips.ap-southeast-1.amazonaws.com", + signingRegion: "ap-southeast-1", + }, + "fips-ap-southeast-2": { + hostname: "elasticfilesystem-fips.ap-southeast-2.amazonaws.com", + signingRegion: "ap-southeast-2", + }, + "fips-ca-central-1": { + hostname: "elasticfilesystem-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-cn-north-1": { + hostname: "elasticfilesystem-fips.cn-north-1.amazonaws.com.cn", + signingRegion: "cn-north-1", + }, + "fips-cn-northwest-1": { + hostname: "elasticfilesystem-fips.cn-northwest-1.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "fips-eu-central-1": { + hostname: "elasticfilesystem-fips.eu-central-1.amazonaws.com", + signingRegion: "eu-central-1", + }, + "fips-eu-north-1": { + hostname: "elasticfilesystem-fips.eu-north-1.amazonaws.com", + signingRegion: "eu-north-1", + }, + "fips-eu-south-1": { + hostname: "elasticfilesystem-fips.eu-south-1.amazonaws.com", + signingRegion: "eu-south-1", + }, + "fips-eu-west-1": { + hostname: "elasticfilesystem-fips.eu-west-1.amazonaws.com", + signingRegion: "eu-west-1", + }, + "fips-eu-west-2": { + hostname: "elasticfilesystem-fips.eu-west-2.amazonaws.com", + signingRegion: "eu-west-2", + }, + "fips-eu-west-3": { + hostname: "elasticfilesystem-fips.eu-west-3.amazonaws.com", + signingRegion: "eu-west-3", + }, + "fips-me-south-1": { + hostname: "elasticfilesystem-fips.me-south-1.amazonaws.com", + signingRegion: "me-south-1", + }, + "fips-sa-east-1": { + hostname: "elasticfilesystem-fips.sa-east-1.amazonaws.com", + signingRegion: "sa-east-1", + }, + "fips-us-east-1": { + hostname: "elasticfilesystem-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "elasticfilesystem-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "elasticfilesystem-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "elasticfilesystem-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-iso-east-1": { + hostname: "elasticfilesystem-fips.us-iso-east-1.c2s.ic.gov", + signingRegion: "us-iso-east-1", + }, + "fips-us-west-1": { + hostname: "elasticfilesystem-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "elasticfilesystem-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "elasticfilesystem.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "elasticfilesystem.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "elasticfilesystem.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "elasticfilesystem.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "elasticfilesystem.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "elasticfilesystem.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "elasticfilesystem.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "elasticfilesystem.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "elasticfilesystem.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "elasticfilesystem.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "elasticfilesystem.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "elasticfilesystem.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "elasticfilesystem.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "elasticfilesystem.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "elasticfilesystem.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "elasticfilesystem.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "elasticfilesystem.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-af-south-1": - regionInfo = { - hostname: "elasticfilesystem-fips.af-south-1.amazonaws.com", - partition: "aws", - signingRegion: "af-south-1", - }; - break; - case "fips-ap-east-1": - regionInfo = { - hostname: "elasticfilesystem-fips.ap-east-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-east-1", - }; - break; - case "fips-ap-northeast-1": - regionInfo = { - hostname: "elasticfilesystem-fips.ap-northeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-1", - }; - break; - case "fips-ap-northeast-2": - regionInfo = { - hostname: "elasticfilesystem-fips.ap-northeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-2", - }; - break; - case "fips-ap-northeast-3": - regionInfo = { - hostname: "elasticfilesystem-fips.ap-northeast-3.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-3", - }; - break; - case "fips-ap-south-1": - regionInfo = { - hostname: "elasticfilesystem-fips.ap-south-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-south-1", - }; - break; - case "fips-ap-southeast-1": - regionInfo = { - hostname: "elasticfilesystem-fips.ap-southeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-1", - }; - break; - case "fips-ap-southeast-2": - regionInfo = { - hostname: "elasticfilesystem-fips.ap-southeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-2", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "elasticfilesystem-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-cn-north-1": - regionInfo = { - hostname: "elasticfilesystem-fips.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-north-1", - }; - break; - case "fips-cn-northwest-1": - regionInfo = { - hostname: "elasticfilesystem-fips.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "fips-eu-central-1": - regionInfo = { - hostname: "elasticfilesystem-fips.eu-central-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-central-1", - }; - break; - case "fips-eu-north-1": - regionInfo = { - hostname: "elasticfilesystem-fips.eu-north-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-north-1", - }; - break; - case "fips-eu-south-1": - regionInfo = { - hostname: "elasticfilesystem-fips.eu-south-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-south-1", - }; - break; - case "fips-eu-west-1": - regionInfo = { - hostname: "elasticfilesystem-fips.eu-west-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-1", - }; - break; - case "fips-eu-west-2": - regionInfo = { - hostname: "elasticfilesystem-fips.eu-west-2.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-2", - }; - break; - case "fips-eu-west-3": - regionInfo = { - hostname: "elasticfilesystem-fips.eu-west-3.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-3", - }; - break; - case "fips-me-south-1": - regionInfo = { - hostname: "elasticfilesystem-fips.me-south-1.amazonaws.com", - partition: "aws", - signingRegion: "me-south-1", - }; - break; - case "fips-sa-east-1": - regionInfo = { - hostname: "elasticfilesystem-fips.sa-east-1.amazonaws.com", - partition: "aws", - signingRegion: "sa-east-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "elasticfilesystem-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "elasticfilesystem-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "elasticfilesystem-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "elasticfilesystem-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-iso-east-1": - regionInfo = { - hostname: "elasticfilesystem-fips.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - signingRegion: "us-iso-east-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "elasticfilesystem-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "elasticfilesystem-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "elasticfilesystem.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "elasticfilesystem.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "elasticfilesystem.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "elasticfilesystem.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "elasticfilesystem.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "elasticfilesystem.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "elasticfilesystem.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "elasticfilesystem.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "elasticfilesystem.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "elasticfilesystem", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-af-south-1", + "fips-ap-east-1", + "fips-ap-northeast-1", + "fips-ap-northeast-2", + "fips-ap-northeast-3", + "fips-ap-south-1", + "fips-ap-southeast-1", + "fips-ap-southeast-2", + "fips-ca-central-1", + "fips-eu-central-1", + "fips-eu-north-1", + "fips-eu-south-1", + "fips-eu-west-1", + "fips-eu-west-2", + "fips-eu-west-3", + "fips-me-south-1", + "fips-sa-east-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "elasticfilesystem.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1", "fips-cn-north-1", "fips-cn-northwest-1"], + hostname: "elasticfilesystem.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["fips-us-iso-east-1", "us-iso-east-1"], + hostname: "elasticfilesystem.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "elasticfilesystem.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "elasticfilesystem.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "elasticfilesystem", + regionHash, + partitionHash, + }); diff --git a/clients/client-eks/endpoints.ts b/clients/client-eks/endpoints.ts index 986eb4f0acb79..22283bde81a76 100644 --- a/clients/client-eks/endpoints.ts +++ b/clients/client-eks/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "eks.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "eks.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "eks.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "eks.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "eks.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "fips.eks.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "fips.eks.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "eks.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "eks.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "fips.eks.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "fips.eks.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "eks.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "eks.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "eks.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "eks.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "eks.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "eks.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "eks.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "eks.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "eks.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "eks.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "eks.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "eks.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "eks.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "eks.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "eks.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "eks.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "eks.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "fips.eks.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "fips.eks.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "eks.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "eks.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "fips.eks.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "fips.eks.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "eks.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "eks.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "eks.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "eks.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "eks.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "eks.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "eks.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "eks.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "eks", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "eks.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "eks.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "eks.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "eks.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "eks.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "eks", + regionHash, + partitionHash, + }); diff --git a/clients/client-elastic-beanstalk/endpoints.ts b/clients/client-elastic-beanstalk/endpoints.ts index 940a9e7aaa357..43864883bf181 100644 --- a/clients/client-elastic-beanstalk/endpoints.ts +++ b/clients/client-elastic-beanstalk/endpoints.ts @@ -1,264 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "elasticbeanstalk.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "elasticbeanstalk.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "elasticbeanstalk.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "elasticbeanstalk.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "elasticbeanstalk.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "elasticbeanstalk-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "elasticbeanstalk-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "elasticbeanstalk-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "elasticbeanstalk-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "elasticbeanstalk.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "elasticbeanstalk.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "elasticbeanstalk.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "elasticbeanstalk.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "elasticbeanstalk.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "elasticbeanstalk.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "elasticbeanstalk.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "elasticbeanstalk.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "elasticbeanstalk.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "elasticbeanstalk.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "elasticbeanstalk.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "elasticbeanstalk.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "elasticbeanstalk.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "elasticbeanstalk.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "elasticbeanstalk.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "elasticbeanstalk.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "elasticbeanstalk.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "elasticbeanstalk.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "elasticbeanstalk.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "elasticbeanstalk-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "elasticbeanstalk-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "elasticbeanstalk-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "elasticbeanstalk-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "elasticbeanstalk.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "elasticbeanstalk.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "elasticbeanstalk.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "elasticbeanstalk.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "elasticbeanstalk.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "elasticbeanstalk.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "elasticbeanstalk.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "elasticbeanstalk.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "elasticbeanstalk", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "elasticbeanstalk.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "elasticbeanstalk.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "elasticbeanstalk.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "elasticbeanstalk.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "elasticbeanstalk.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "elasticbeanstalk", + regionHash, + partitionHash, + }); diff --git a/clients/client-elastic-inference/endpoints.ts b/clients/client-elastic-inference/endpoints.ts index c35d02dc35258..059a6d758d775 100644 --- a/clients/client-elastic-inference/endpoints.ts +++ b/clients/client-elastic-inference/endpoints.ts @@ -1,120 +1,76 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "api.elastic-inference.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "api.elastic-inference.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "api.elastic-inference.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "api.elastic-inference.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "api.elastic-inference.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "ap-northeast-1": { + hostname: "api.elastic-inference.ap-northeast-1.amazonaws.com", + }, + "ap-northeast-2": { + hostname: "api.elastic-inference.ap-northeast-2.amazonaws.com", + }, + "eu-west-1": { + hostname: "api.elastic-inference.eu-west-1.amazonaws.com", + }, + "us-east-1": { + hostname: "api.elastic-inference.us-east-1.amazonaws.com", + }, + "us-east-2": { + hostname: "api.elastic-inference.us-east-2.amazonaws.com", + }, + "us-west-2": { + hostname: "api.elastic-inference.us-west-2.amazonaws.com", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "api.elastic-inference.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "api.elastic-inference.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "api.elastic-inference.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "api.elastic-inference.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "api.elastic-inference.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "api.elastic-inference.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "elastic-inference", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "api.elastic-inference.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "api.elastic-inference.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "api.elastic-inference.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "api.elastic-inference.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "api.elastic-inference.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "elastic-inference", + regionHash, + partitionHash, + }); diff --git a/clients/client-elastic-load-balancing-v2/endpoints.ts b/clients/client-elastic-load-balancing-v2/endpoints.ts index 9ea868898d033..40f97b855b6c6 100644 --- a/clients/client-elastic-load-balancing-v2/endpoints.ts +++ b/clients/client-elastic-load-balancing-v2/endpoints.ts @@ -1,288 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "elasticloadbalancing.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "elasticloadbalancing.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "elasticloadbalancing.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "elasticloadbalancing.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "elasticloadbalancing.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "elasticloadbalancing-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "elasticloadbalancing-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "elasticloadbalancing.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "elasticloadbalancing.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "elasticloadbalancing-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "elasticloadbalancing-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "elasticloadbalancing.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "elasticloadbalancing.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "elasticloadbalancing.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "elasticloadbalancing.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "elasticloadbalancing.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "elasticloadbalancing.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "elasticloadbalancing.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "elasticloadbalancing.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "elasticloadbalancing.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "elasticloadbalancing.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "elasticloadbalancing.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "elasticloadbalancing.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "elasticloadbalancing.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "elasticloadbalancing.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "elasticloadbalancing.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "elasticloadbalancing.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "elasticloadbalancing.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "elasticloadbalancing-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "elasticloadbalancing-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "elasticloadbalancing.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "elasticloadbalancing.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "elasticloadbalancing-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "elasticloadbalancing-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "elasticloadbalancing.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "elasticloadbalancing.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "elasticloadbalancing.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "elasticloadbalancing.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "elasticloadbalancing.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "elasticloadbalancing.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "elasticloadbalancing.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "elasticloadbalancing.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "elasticloadbalancing.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "elasticloadbalancing.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "elasticloadbalancing", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "elasticloadbalancing.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "elasticloadbalancing.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "elasticloadbalancing.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "elasticloadbalancing.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "elasticloadbalancing.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "elasticloadbalancing", + regionHash, + partitionHash, + }); diff --git a/clients/client-elastic-load-balancing/endpoints.ts b/clients/client-elastic-load-balancing/endpoints.ts index 9ea868898d033..40f97b855b6c6 100644 --- a/clients/client-elastic-load-balancing/endpoints.ts +++ b/clients/client-elastic-load-balancing/endpoints.ts @@ -1,288 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "elasticloadbalancing.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "elasticloadbalancing.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "elasticloadbalancing.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "elasticloadbalancing.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "elasticloadbalancing.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "elasticloadbalancing-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "elasticloadbalancing-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "elasticloadbalancing.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "elasticloadbalancing.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "elasticloadbalancing-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "elasticloadbalancing-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "elasticloadbalancing.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "elasticloadbalancing.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "elasticloadbalancing.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "elasticloadbalancing.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "elasticloadbalancing.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "elasticloadbalancing.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "elasticloadbalancing.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "elasticloadbalancing.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "elasticloadbalancing.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "elasticloadbalancing.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "elasticloadbalancing.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "elasticloadbalancing.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "elasticloadbalancing.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "elasticloadbalancing.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "elasticloadbalancing.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "elasticloadbalancing.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "elasticloadbalancing.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "elasticloadbalancing-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "elasticloadbalancing-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "elasticloadbalancing.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "elasticloadbalancing.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "elasticloadbalancing-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "elasticloadbalancing-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "elasticloadbalancing.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "elasticloadbalancing.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "elasticloadbalancing.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "elasticloadbalancing.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "elasticloadbalancing.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "elasticloadbalancing.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "elasticloadbalancing.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "elasticloadbalancing.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "elasticloadbalancing.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "elasticloadbalancing.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "elasticloadbalancing", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "elasticloadbalancing.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "elasticloadbalancing.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "elasticloadbalancing.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "elasticloadbalancing.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "elasticloadbalancing.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "elasticloadbalancing", + regionHash, + partitionHash, + }); diff --git a/clients/client-elastic-transcoder/endpoints.ts b/clients/client-elastic-transcoder/endpoints.ts index 921761a6155eb..44baf861a4f9c 100644 --- a/clients/client-elastic-transcoder/endpoints.ts +++ b/clients/client-elastic-transcoder/endpoints.ts @@ -1,132 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "elastictranscoder.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "elastictranscoder.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "elastictranscoder.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "elastictranscoder.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "elastictranscoder.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "elastictranscoder.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "elastictranscoder.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "elastictranscoder.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "elastictranscoder.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "elastictranscoder.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "elastictranscoder.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "elastictranscoder.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "elastictranscoder.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "elastictranscoder", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "elastictranscoder.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "elastictranscoder.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "elastictranscoder.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "elastictranscoder.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "elastictranscoder.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "elastictranscoder", + regionHash, + partitionHash, + }); diff --git a/clients/client-elasticache/endpoints.ts b/clients/client-elasticache/endpoints.ts index af5d4de058445..f71393a74a244 100644 --- a/clients/client-elasticache/endpoints.ts +++ b/clients/client-elasticache/endpoints.ts @@ -1,253 +1,63 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "elasticache.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "elasticache.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "elasticache.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "elasticache.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "elasticache.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + fips: { + hostname: "elasticache.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "elasticache.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "elasticache.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "elasticache.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "elasticache.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "elasticache.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "elasticache.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "elasticache.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "elasticache.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "elasticache.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "elasticache.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "elasticache.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "elasticache.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "elasticache.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "elasticache.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "elasticache.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "elasticache.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "elasticache.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips": - regionInfo = { - hostname: "elasticache.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "elasticache.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "elasticache.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "elasticache.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "elasticache.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "elasticache.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "elasticache.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "elasticache.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "elasticache.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "elasticache.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "elasticache.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "elasticache", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "elasticache.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "elasticache.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "elasticache.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "elasticache.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips", "us-gov-east-1", "us-gov-west-1"], + hostname: "elasticache.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "elasticache", + regionHash, + partitionHash, + }); diff --git a/clients/client-elasticsearch-service/endpoints.ts b/clients/client-elasticsearch-service/endpoints.ts index 03947c9193f34..b250df0f90db2 100644 --- a/clients/client-elasticsearch-service/endpoints.ts +++ b/clients/client-elasticsearch-service/endpoints.ts @@ -1,253 +1,63 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "es.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "es.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "es.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "es.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "es.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + fips: { + hostname: "es-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "es.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "es.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "es.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "es.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "es.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "es.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "es.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "es.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "es.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "es.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "es.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "es.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "es.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "es.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "es.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "es.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "es.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips": - regionInfo = { - hostname: "es-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "es.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "es.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "es.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "es.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "es.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "es.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "es.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "es.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "es.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "es.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "es", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "es.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "es.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "es.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "es.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips", "us-gov-east-1", "us-gov-west-1"], + hostname: "es.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "es", + regionHash, + partitionHash, + }); diff --git a/clients/client-emr-containers/endpoints.ts b/clients/client-emr-containers/endpoints.ts index 5215220ef15bb..d3cd1b1b75780 100644 --- a/clients/client-emr-containers/endpoints.ts +++ b/clients/client-emr-containers/endpoints.ts @@ -1,215 +1,83 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "emr-containers.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "emr-containers.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "emr-containers.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "emr-containers.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "emr-containers.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "emr-containers-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "emr-containers-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "emr-containers-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "emr-containers-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "emr-containers-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "emr-containers.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "emr-containers.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "emr-containers.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "emr-containers.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "emr-containers.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "emr-containers.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "emr-containers.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "emr-containers.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "emr-containers.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "emr-containers.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "emr-containers.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "emr-containers-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "emr-containers-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "emr-containers-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "emr-containers-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "emr-containers-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "emr-containers.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "emr-containers.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "emr-containers.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "emr-containers.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "emr-containers.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "emr-containers", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "emr-containers.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "emr-containers.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "emr-containers.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "emr-containers.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "emr-containers.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "emr-containers", + regionHash, + partitionHash, + }); diff --git a/clients/client-emr/endpoints.ts b/clients/client-emr/endpoints.ts index 72af3fcb6a37a..b943593cb2aac 100644 --- a/clients/client-emr/endpoints.ts +++ b/clients/client-emr/endpoints.ts @@ -1,295 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "elasticmapreduce.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "elasticmapreduce.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "elasticmapreduce.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "elasticmapreduce.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "elasticmapreduce.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "elasticmapreduce-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "elasticmapreduce-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "elasticmapreduce-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "elasticmapreduce.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "elasticmapreduce.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "elasticmapreduce-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "elasticmapreduce-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "elasticmapreduce.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "elasticmapreduce.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "elasticmapreduce.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "elasticmapreduce.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "elasticmapreduce.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "elasticmapreduce.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "elasticmapreduce.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "elasticmapreduce.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "elasticmapreduce.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "elasticmapreduce.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "elasticmapreduce.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "elasticmapreduce.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "elasticmapreduce.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "elasticmapreduce.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "elasticmapreduce.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "elasticmapreduce.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "elasticmapreduce.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "elasticmapreduce-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "elasticmapreduce-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "elasticmapreduce-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "elasticmapreduce.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "elasticmapreduce.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "elasticmapreduce-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "elasticmapreduce-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "elasticmapreduce.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "elasticmapreduce.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "elasticmapreduce.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "elasticmapreduce.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "elasticmapreduce.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "elasticmapreduce.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "elasticmapreduce.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "elasticmapreduce.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "elasticmapreduce.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "elasticmapreduce.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "elasticmapreduce", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "elasticmapreduce.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "elasticmapreduce.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "elasticmapreduce.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "elasticmapreduce.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "elasticmapreduce.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "elasticmapreduce", + regionHash, + partitionHash, + }); diff --git a/clients/client-eventbridge/endpoints.ts b/clients/client-eventbridge/endpoints.ts index 118077ce795bf..99dac1f1644e6 100644 --- a/clients/client-eventbridge/endpoints.ts +++ b/clients/client-eventbridge/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "events.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "events.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "events.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "events.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "events.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "events-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "events-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "events-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "events-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "events.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "events.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "events.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "events.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "events.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "events.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "events.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "events.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "events.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "events.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "events.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "events.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "events.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "events.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "events.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "events.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "events.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "events.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "events.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "events-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "events-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "events-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "events-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "events.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "events.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "events.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "events.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "events.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "events.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "events.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "events.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "events.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "events.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "events", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "events.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "events.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "events.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "events.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "events.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "events", + regionHash, + partitionHash, + }); diff --git a/clients/client-finspace-data/endpoints.ts b/clients/client-finspace-data/endpoints.ts index 0c52d4dc59007..8f6259addcd07 100644 --- a/clients/client-finspace-data/endpoints.ts +++ b/clients/client-finspace-data/endpoints.ts @@ -1,114 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "finspace-api.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "finspace-api.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "finspace-api.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "finspace-api.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "finspace-api.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ca-central-1": - regionInfo = { - hostname: "finspace-api.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "finspace-api.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "finspace-api.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "finspace-api.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "finspace-api.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "finspace-api", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "finspace-api.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "finspace-api.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "finspace-api.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "finspace-api.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "finspace-api.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "finspace-api", + regionHash, + partitionHash, + }); diff --git a/clients/client-finspace/endpoints.ts b/clients/client-finspace/endpoints.ts index 87383510a3611..61e746eef3e40 100644 --- a/clients/client-finspace/endpoints.ts +++ b/clients/client-finspace/endpoints.ts @@ -1,114 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "finspace.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "finspace.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "finspace.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "finspace.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "finspace.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ca-central-1": - regionInfo = { - hostname: "finspace.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "finspace.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "finspace.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "finspace.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "finspace.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "finspace", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "finspace.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "finspace.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "finspace.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "finspace.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "finspace.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "finspace", + regionHash, + partitionHash, + }); diff --git a/clients/client-firehose/endpoints.ts b/clients/client-firehose/endpoints.ts index 2672741da1cea..8e8d44c0bae85 100644 --- a/clients/client-firehose/endpoints.ts +++ b/clients/client-firehose/endpoints.ts @@ -1,282 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "firehose.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "firehose.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "firehose.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "firehose.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "firehose.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "firehose-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "firehose-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "firehose-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "firehose-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "firehose-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "firehose-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "firehose.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "firehose.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "firehose.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "firehose.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "firehose.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "firehose.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "firehose.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "firehose.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "firehose.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "firehose.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "firehose.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "firehose.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "firehose.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "firehose.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "firehose.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "firehose.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "firehose.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "firehose-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "firehose-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "firehose-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "firehose-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "firehose-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "firehose-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "firehose.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "firehose.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "firehose.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "firehose.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "firehose.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "firehose.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "firehose.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "firehose.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "firehose.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "firehose", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "firehose.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "firehose.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "firehose.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "firehose.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "firehose.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "firehose", + regionHash, + partitionHash, + }); diff --git a/clients/client-fis/endpoints.ts b/clients/client-fis/endpoints.ts index f090bfbbe3432..6a6cc765740cb 100644 --- a/clients/client-fis/endpoints.ts +++ b/clients/client-fis/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "fis.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "fis.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "fis.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "fis.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "fis.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "fis", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "fis.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "fis.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "fis.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "fis.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "fis.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "fis", + regionHash, + partitionHash, + }); diff --git a/clients/client-fms/endpoints.ts b/clients/client-fms/endpoints.ts index c5a730e962e1a..8f29da561fedd 100644 --- a/clients/client-fms/endpoints.ts +++ b/clients/client-fms/endpoints.ts @@ -1,369 +1,161 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "fms.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "fms.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "fms.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "fms.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "fms.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-af-south-1": { + hostname: "fms-fips.af-south-1.amazonaws.com", + signingRegion: "af-south-1", + }, + "fips-ap-east-1": { + hostname: "fms-fips.ap-east-1.amazonaws.com", + signingRegion: "ap-east-1", + }, + "fips-ap-northeast-1": { + hostname: "fms-fips.ap-northeast-1.amazonaws.com", + signingRegion: "ap-northeast-1", + }, + "fips-ap-northeast-2": { + hostname: "fms-fips.ap-northeast-2.amazonaws.com", + signingRegion: "ap-northeast-2", + }, + "fips-ap-south-1": { + hostname: "fms-fips.ap-south-1.amazonaws.com", + signingRegion: "ap-south-1", + }, + "fips-ap-southeast-1": { + hostname: "fms-fips.ap-southeast-1.amazonaws.com", + signingRegion: "ap-southeast-1", + }, + "fips-ap-southeast-2": { + hostname: "fms-fips.ap-southeast-2.amazonaws.com", + signingRegion: "ap-southeast-2", + }, + "fips-ca-central-1": { + hostname: "fms-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-eu-central-1": { + hostname: "fms-fips.eu-central-1.amazonaws.com", + signingRegion: "eu-central-1", + }, + "fips-eu-south-1": { + hostname: "fms-fips.eu-south-1.amazonaws.com", + signingRegion: "eu-south-1", + }, + "fips-eu-west-1": { + hostname: "fms-fips.eu-west-1.amazonaws.com", + signingRegion: "eu-west-1", + }, + "fips-eu-west-2": { + hostname: "fms-fips.eu-west-2.amazonaws.com", + signingRegion: "eu-west-2", + }, + "fips-eu-west-3": { + hostname: "fms-fips.eu-west-3.amazonaws.com", + signingRegion: "eu-west-3", + }, + "fips-me-south-1": { + hostname: "fms-fips.me-south-1.amazonaws.com", + signingRegion: "me-south-1", + }, + "fips-sa-east-1": { + hostname: "fms-fips.sa-east-1.amazonaws.com", + signingRegion: "sa-east-1", + }, + "fips-us-east-1": { + hostname: "fms-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "fms-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "fms-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "fms-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "fms-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "fms-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "fms.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "fms.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "fms.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "fms.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "fms.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "fms.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "fms.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "fms.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "fms.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "fms.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "fms.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "fms.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "fms.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "fms.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "fms.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-af-south-1": - regionInfo = { - hostname: "fms-fips.af-south-1.amazonaws.com", - partition: "aws", - signingRegion: "af-south-1", - }; - break; - case "fips-ap-east-1": - regionInfo = { - hostname: "fms-fips.ap-east-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-east-1", - }; - break; - case "fips-ap-northeast-1": - regionInfo = { - hostname: "fms-fips.ap-northeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-1", - }; - break; - case "fips-ap-northeast-2": - regionInfo = { - hostname: "fms-fips.ap-northeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-2", - }; - break; - case "fips-ap-south-1": - regionInfo = { - hostname: "fms-fips.ap-south-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-south-1", - }; - break; - case "fips-ap-southeast-1": - regionInfo = { - hostname: "fms-fips.ap-southeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-1", - }; - break; - case "fips-ap-southeast-2": - regionInfo = { - hostname: "fms-fips.ap-southeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-2", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "fms-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-eu-central-1": - regionInfo = { - hostname: "fms-fips.eu-central-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-central-1", - }; - break; - case "fips-eu-south-1": - regionInfo = { - hostname: "fms-fips.eu-south-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-south-1", - }; - break; - case "fips-eu-west-1": - regionInfo = { - hostname: "fms-fips.eu-west-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-1", - }; - break; - case "fips-eu-west-2": - regionInfo = { - hostname: "fms-fips.eu-west-2.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-2", - }; - break; - case "fips-eu-west-3": - regionInfo = { - hostname: "fms-fips.eu-west-3.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-3", - }; - break; - case "fips-me-south-1": - regionInfo = { - hostname: "fms-fips.me-south-1.amazonaws.com", - partition: "aws", - signingRegion: "me-south-1", - }; - break; - case "fips-sa-east-1": - regionInfo = { - hostname: "fms-fips.sa-east-1.amazonaws.com", - partition: "aws", - signingRegion: "sa-east-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "fms-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "fms-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "fms-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "fms-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "fms-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "fms-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "fms.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "fms.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "fms.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "fms.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "fms.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "fms.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "fms.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "fms.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "fms", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-af-south-1", + "fips-ap-east-1", + "fips-ap-northeast-1", + "fips-ap-northeast-2", + "fips-ap-south-1", + "fips-ap-southeast-1", + "fips-ap-southeast-2", + "fips-ca-central-1", + "fips-eu-central-1", + "fips-eu-south-1", + "fips-eu-west-1", + "fips-eu-west-2", + "fips-eu-west-3", + "fips-me-south-1", + "fips-sa-east-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "fms.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "fms.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "fms.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "fms.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "fms.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "fms", + regionHash, + partitionHash, + }); diff --git a/clients/client-forecast/endpoints.ts b/clients/client-forecast/endpoints.ts index 6dd3d60942785..01ac310469251 100644 --- a/clients/client-forecast/endpoints.ts +++ b/clients/client-forecast/endpoints.ts @@ -1,165 +1,73 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "forecast.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "forecast.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "forecast.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "forecast.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "forecast.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "forecast-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "forecast-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-2": { + hostname: "forecast-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "forecast.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "forecast.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "forecast.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "forecast.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "forecast.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "forecast.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "forecast.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "forecast-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "forecast-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "forecast-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "forecast.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "forecast.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "forecast.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "forecast", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "forecast.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "forecast.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "forecast.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "forecast.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "forecast.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "forecast", + regionHash, + partitionHash, + }); diff --git a/clients/client-forecastquery/endpoints.ts b/clients/client-forecastquery/endpoints.ts index 20a3a95dc0632..4772acd39bb4a 100644 --- a/clients/client-forecastquery/endpoints.ts +++ b/clients/client-forecastquery/endpoints.ts @@ -1,165 +1,73 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "forecastquery.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "forecastquery.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "forecastquery.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "forecastquery.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "forecastquery.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "forecastquery-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "forecastquery-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-2": { + hostname: "forecastquery-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "forecastquery.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "forecastquery.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "forecastquery.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "forecastquery.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "forecastquery.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "forecastquery.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "forecastquery.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "forecastquery-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "forecastquery-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "forecastquery-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "forecastquery.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "forecastquery.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "forecastquery.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "forecast", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "forecastquery.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "forecastquery.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "forecastquery.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "forecastquery.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "forecastquery.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "forecast", + regionHash, + partitionHash, + }); diff --git a/clients/client-frauddetector/endpoints.ts b/clients/client-frauddetector/endpoints.ts index 269c4db78bbe7..30d071d594ca1 100644 --- a/clients/client-frauddetector/endpoints.ts +++ b/clients/client-frauddetector/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "frauddetector.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "frauddetector.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "frauddetector.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "frauddetector.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "frauddetector.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "frauddetector", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "frauddetector.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "frauddetector.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "frauddetector.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "frauddetector.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "frauddetector.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "frauddetector", + regionHash, + partitionHash, + }); diff --git a/clients/client-fsx/endpoints.ts b/clients/client-fsx/endpoints.ts index d92202fa52297..a3dbc1c24c2fa 100644 --- a/clients/client-fsx/endpoints.ts +++ b/clients/client-fsx/endpoints.ts @@ -1,283 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "fsx.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "fsx.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "fsx.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "fsx.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "fsx.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-prod-ca-central-1": { + hostname: "fsx-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-prod-us-east-1": { + hostname: "fsx-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-prod-us-east-2": { + hostname: "fsx-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-prod-us-gov-east-1": { + hostname: "fsx-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-prod-us-gov-west-1": { + hostname: "fsx-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-prod-us-west-1": { + hostname: "fsx-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-prod-us-west-2": { + hostname: "fsx-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "fsx.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "fsx.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "fsx.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "fsx.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "fsx.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "fsx.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "fsx.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "fsx.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "fsx.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "fsx.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "fsx.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "fsx.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "fsx.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "fsx.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "fsx.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "fsx.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "fsx.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-prod-ca-central-1": - regionInfo = { - hostname: "fsx-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-prod-us-east-1": - regionInfo = { - hostname: "fsx-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-prod-us-east-2": - regionInfo = { - hostname: "fsx-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-prod-us-gov-east-1": - regionInfo = { - hostname: "fsx-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-prod-us-gov-west-1": - regionInfo = { - hostname: "fsx-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-prod-us-west-1": - regionInfo = { - hostname: "fsx-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-prod-us-west-2": - regionInfo = { - hostname: "fsx-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "fsx.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "fsx.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "fsx.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "fsx.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "fsx.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "fsx.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "fsx.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "fsx.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "fsx", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-prod-ca-central-1", + "fips-prod-us-east-1", + "fips-prod-us-east-2", + "fips-prod-us-west-1", + "fips-prod-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "fsx.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "fsx.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "fsx.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "fsx.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-prod-us-gov-east-1", "fips-prod-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "fsx.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "fsx", + regionHash, + partitionHash, + }); diff --git a/clients/client-gamelift/endpoints.ts b/clients/client-gamelift/endpoints.ts index b8cdd033b8bd1..d868d5e36e1e4 100644 --- a/clients/client-gamelift/endpoints.ts +++ b/clients/client-gamelift/endpoints.ts @@ -1,216 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "gamelift.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "gamelift.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "gamelift.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "gamelift.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "gamelift.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "gamelift.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "gamelift.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "gamelift.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "gamelift.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "gamelift.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "gamelift.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "gamelift.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "gamelift.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "gamelift.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "gamelift.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "gamelift.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "gamelift.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "gamelift.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "gamelift.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "gamelift.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "gamelift.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "gamelift.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "gamelift.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "gamelift.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "gamelift.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "gamelift.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "gamelift.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "gamelift", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "gamelift.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "gamelift.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "gamelift.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "gamelift.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "gamelift.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "gamelift", + regionHash, + partitionHash, + }); diff --git a/clients/client-glacier/endpoints.ts b/clients/client-glacier/endpoints.ts index bdc691482e9fd..9e609496a10f6 100644 --- a/clients/client-glacier/endpoints.ts +++ b/clients/client-glacier/endpoints.ts @@ -1,283 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "glacier.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "glacier.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "glacier.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "glacier.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "glacier.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "glacier-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "glacier-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "glacier-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "glacier-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "glacier-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "glacier.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "glacier.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "glacier.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "glacier.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "glacier.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "glacier.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "glacier.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "glacier.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "glacier.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "glacier.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "glacier.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "glacier.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "glacier.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "glacier.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "glacier.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "glacier.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "glacier.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "glacier.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "glacier.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "glacier-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "glacier-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "glacier-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "glacier-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "glacier-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "glacier.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "glacier.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "glacier.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "glacier.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "glacier.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "glacier.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "glacier.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "glacier.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "glacier.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "glacier.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "glacier", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "glacier.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "glacier.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "glacier.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "glacier.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "glacier.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "glacier", + regionHash, + partitionHash, + }); diff --git a/clients/client-global-accelerator/endpoints.ts b/clients/client-global-accelerator/endpoints.ts index 3730115058437..1179aad630077 100644 --- a/clients/client-global-accelerator/endpoints.ts +++ b/clients/client-global-accelerator/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "globalaccelerator.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "globalaccelerator.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "globalaccelerator.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "globalaccelerator.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "globalaccelerator.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "globalaccelerator", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "globalaccelerator.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "globalaccelerator.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "globalaccelerator.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "globalaccelerator.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "globalaccelerator.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "globalaccelerator", + regionHash, + partitionHash, + }); diff --git a/clients/client-glue/endpoints.ts b/clients/client-glue/endpoints.ts index 27d3ea7e4ae14..8522f6bbe01e6 100644 --- a/clients/client-glue/endpoints.ts +++ b/clients/client-glue/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "glue.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "glue.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "glue.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "glue.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "glue.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "glue-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "glue-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "glue-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "glue-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "glue-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "glue-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "glue.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "glue.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "glue.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "glue.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "glue.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "glue.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "glue.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "glue.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "glue.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "glue.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "glue.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "glue.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "glue.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "glue.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "glue.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "glue.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "glue.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "glue-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "glue-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "glue-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "glue-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "glue-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "glue-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "glue.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "glue.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "glue.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "glue.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "glue.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "glue.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "glue.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "glue.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "glue", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "glue.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "glue.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "glue.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "glue.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "glue.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "glue", + regionHash, + partitionHash, + }); diff --git a/clients/client-greengrass/endpoints.ts b/clients/client-greengrass/endpoints.ts index 3c0c0d6890ba8..4efe1e22b4419 100644 --- a/clients/client-greengrass/endpoints.ts +++ b/clients/client-greengrass/endpoints.ts @@ -1,191 +1,84 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "greengrass.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "greengrass.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "greengrass.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "greengrass.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "greengrass.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "dataplane-us-gov-east-1": { + hostname: "greengrass-ats.iot.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "dataplane-us-gov-west-1": { + hostname: "greengrass-ats.iot.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-gov-east-1": { + hostname: "greengrass-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-east-1": { + hostname: "greengrass.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "greengrass.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "greengrass.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "greengrass.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "greengrass.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "greengrass.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "greengrass.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "greengrass.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "dataplane-us-gov-east-1": - regionInfo = { - hostname: "greengrass-ats.iot.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "dataplane-us-gov-west-1": - regionInfo = { - hostname: "greengrass-ats.iot.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "greengrass.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "greengrass.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "greengrass.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "greengrass-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "greengrass.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "greengrass.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "greengrass.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "greengrass.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "greengrass.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "greengrass", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "greengrass.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "greengrass.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "greengrass.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "greengrass.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: [ + "dataplane-us-gov-east-1", + "dataplane-us-gov-west-1", + "fips-us-gov-east-1", + "us-gov-east-1", + "us-gov-west-1", + ], + hostname: "greengrass.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "greengrass", + regionHash, + partitionHash, + }); diff --git a/clients/client-greengrassv2/endpoints.ts b/clients/client-greengrassv2/endpoints.ts index 3c0c0d6890ba8..4efe1e22b4419 100644 --- a/clients/client-greengrassv2/endpoints.ts +++ b/clients/client-greengrassv2/endpoints.ts @@ -1,191 +1,84 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "greengrass.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "greengrass.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "greengrass.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "greengrass.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "greengrass.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "dataplane-us-gov-east-1": { + hostname: "greengrass-ats.iot.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "dataplane-us-gov-west-1": { + hostname: "greengrass-ats.iot.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-gov-east-1": { + hostname: "greengrass-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-east-1": { + hostname: "greengrass.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "greengrass.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "greengrass.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "greengrass.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "greengrass.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "greengrass.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "greengrass.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "greengrass.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "dataplane-us-gov-east-1": - regionInfo = { - hostname: "greengrass-ats.iot.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "dataplane-us-gov-west-1": - regionInfo = { - hostname: "greengrass-ats.iot.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "greengrass.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "greengrass.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "greengrass.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "greengrass-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "greengrass.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "greengrass.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "greengrass.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "greengrass.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "greengrass.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "greengrass", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "greengrass.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "greengrass.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "greengrass.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "greengrass.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: [ + "dataplane-us-gov-east-1", + "dataplane-us-gov-west-1", + "fips-us-gov-east-1", + "us-gov-east-1", + "us-gov-west-1", + ], + hostname: "greengrass.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "greengrass", + regionHash, + partitionHash, + }); diff --git a/clients/client-groundstation/endpoints.ts b/clients/client-groundstation/endpoints.ts index 9e106e2a50e2b..073abbdc29778 100644 --- a/clients/client-groundstation/endpoints.ts +++ b/clients/client-groundstation/endpoints.ts @@ -1,165 +1,73 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "groundstation.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "groundstation.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "groundstation.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "groundstation.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "groundstation.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "groundstation-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "groundstation-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-2": { + hostname: "groundstation-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "groundstation.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "groundstation.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "groundstation.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "groundstation.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "groundstation.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "groundstation.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "groundstation-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "groundstation-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "groundstation-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "groundstation.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "groundstation.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "groundstation.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "groundstation.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "groundstation", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "groundstation.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "groundstation.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "groundstation.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "groundstation.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "groundstation.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "groundstation", + regionHash, + partitionHash, + }); diff --git a/clients/client-guardduty/endpoints.ts b/clients/client-guardduty/endpoints.ts index 09ba14031d955..6487354e45e71 100644 --- a/clients/client-guardduty/endpoints.ts +++ b/clients/client-guardduty/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "guardduty.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "guardduty.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "guardduty.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "guardduty.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "guardduty.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "guardduty-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "guardduty-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1-fips": { + hostname: "guardduty.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1-fips": { + hostname: "guardduty.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "guardduty-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "guardduty-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "guardduty.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "guardduty.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "guardduty.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "guardduty.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "guardduty.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "guardduty.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "guardduty.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "guardduty.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "guardduty.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "guardduty.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "guardduty.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "guardduty.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "guardduty.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "guardduty.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "guardduty.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "guardduty.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "guardduty.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "guardduty.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "guardduty.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "guardduty.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "guardduty-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "guardduty.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "guardduty-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "guardduty.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-east-1-fips": - regionInfo = { - hostname: "guardduty.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "guardduty.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "guardduty.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "guardduty.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "guardduty-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "guardduty.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "guardduty-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "guardduty", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "guardduty.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "guardduty.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "guardduty.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "guardduty.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-east-1-fips", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "guardduty.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "guardduty", + regionHash, + partitionHash, + }); diff --git a/clients/client-health/endpoints.ts b/clients/client-health/endpoints.ts index 0df8b53881de4..15721c59398e6 100644 --- a/clients/client-health/endpoints.ts +++ b/clients/client-health/endpoints.ts @@ -1,122 +1,67 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "health.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "health.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "health.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "health.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "health.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-2": { + hostname: "health-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-west-1": { + hostname: "health-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "cn-north-1": - regionInfo = { - hostname: "health.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "health.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "health-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "health-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "health.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "health.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "health", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "health.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "health.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "health.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "health.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "health.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "health", + regionHash, + partitionHash, + }); diff --git a/clients/client-healthlake/endpoints.ts b/clients/client-healthlake/endpoints.ts index d3b9087b51d40..de8aacaf153e1 100644 --- a/clients/client-healthlake/endpoints.ts +++ b/clients/client-healthlake/endpoints.ts @@ -1,102 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "healthlake.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "healthlake.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "healthlake.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "healthlake.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "healthlake.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "us-east-1": - regionInfo = { - hostname: "healthlake.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "healthlake.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "healthlake.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "healthlake", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "healthlake.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "healthlake.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "healthlake.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "healthlake.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "healthlake.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "healthlake", + regionHash, + partitionHash, + }); diff --git a/clients/client-honeycode/endpoints.ts b/clients/client-honeycode/endpoints.ts index 4239a8336a2ae..d374d3948be52 100644 --- a/clients/client-honeycode/endpoints.ts +++ b/clients/client-honeycode/endpoints.ts @@ -1,90 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "honeycode.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "honeycode.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "honeycode.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "honeycode.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "honeycode.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "us-west-2": - regionInfo = { - hostname: "honeycode.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "honeycode", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "honeycode.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "honeycode.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "honeycode.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "honeycode.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "honeycode.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "honeycode", + regionHash, + partitionHash, + }); diff --git a/clients/client-iam/endpoints.ts b/clients/client-iam/endpoints.ts index 744480f310399..53e46a9eedd54 100644 --- a/clients/client-iam/endpoints.ts +++ b/clients/client-iam/endpoints.ts @@ -1,115 +1,88 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "iam.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "iam.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "iam.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "iam.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "iam.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-cn-global": { + hostname: "iam.cn-north-1.amazonaws.com.cn", + signingRegion: "cn-north-1", + }, + "aws-global": { + hostname: "iam.amazonaws.com", + signingRegion: "us-east-1", + }, + "aws-iso-b-global": { + hostname: "iam.us-isob-east-1.sc2s.sgov.gov", + signingRegion: "us-isob-east-1", + }, + "aws-iso-global": { + hostname: "iam.us-iso-east-1.c2s.ic.gov", + signingRegion: "us-iso-east-1", + }, + "aws-us-gov-global": { + hostname: "iam.us-gov.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "iam-fips": { + hostname: "iam-fips.amazonaws.com", + signingRegion: "us-east-1", + }, + "iam-govcloud-fips": { + hostname: "iam.us-gov.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "aws-cn-global": - regionInfo = { - hostname: "iam.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-north-1", - }; - break; - case "aws-global": - regionInfo = { - hostname: "iam.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "aws-iso-b-global": - regionInfo = { - hostname: "iam.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - signingRegion: "us-isob-east-1", - }; - break; - case "aws-iso-global": - regionInfo = { - hostname: "iam.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - signingRegion: "us-iso-east-1", - }; - break; - case "aws-us-gov-global": - regionInfo = { - hostname: "iam.us-gov.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "iam-fips": - regionInfo = { - hostname: "iam-fips.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "iam-govcloud-fips": - regionInfo = { - hostname: "iam.us-gov.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-global"); - } - if (AWS_CN_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-cn-global"); - } - if (AWS_ISO_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-iso-global"); - } - if (AWS_ISO_B_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-iso-b-global"); - } - if (AWS_US_GOV_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-us-gov-global"); - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - return defaultRegionInfoProvider("aws-global"); - } - } - return Promise.resolve({ signingService: "iam", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "iam-fips", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + endpoint: "aws-global", + }, + "aws-cn": { + regions: ["aws-cn-global", "cn-north-1", "cn-northwest-1"], + endpoint: "aws-cn-global", + }, + "aws-iso": { + regions: ["aws-iso-global", "us-iso-east-1"], + endpoint: "aws-iso-global", + }, + "aws-iso-b": { + regions: ["aws-iso-b-global", "us-isob-east-1"], + endpoint: "aws-iso-b-global", + }, + "aws-us-gov": { + regions: ["aws-us-gov-global", "iam-govcloud-fips", "us-gov-east-1", "us-gov-west-1"], + endpoint: "aws-us-gov-global", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iam", + regionHash, + partitionHash, + }); diff --git a/clients/client-identitystore/endpoints.ts b/clients/client-identitystore/endpoints.ts index ef1aa7518a05f..8460feb506510 100644 --- a/clients/client-identitystore/endpoints.ts +++ b/clients/client-identitystore/endpoints.ts @@ -1,162 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "identitystore.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "identitystore.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "identitystore.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "identitystore.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "identitystore.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "identitystore.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "identitystore.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "identitystore.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "identitystore.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "identitystore.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "identitystore.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "identitystore.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "identitystore.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "identitystore.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "identitystore.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "identitystore.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "identitystore.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "identitystore.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "identitystore", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "identitystore.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "identitystore.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "identitystore.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "identitystore.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "identitystore.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "identitystore", + regionHash, + partitionHash, + }); diff --git a/clients/client-imagebuilder/endpoints.ts b/clients/client-imagebuilder/endpoints.ts index b6cd1f8576be1..6b3c2e31e09d2 100644 --- a/clients/client-imagebuilder/endpoints.ts +++ b/clients/client-imagebuilder/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "imagebuilder.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "imagebuilder.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "imagebuilder.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "imagebuilder.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "imagebuilder.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "imagebuilder", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "imagebuilder.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "imagebuilder.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "imagebuilder.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "imagebuilder.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "imagebuilder.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "imagebuilder", + regionHash, + partitionHash, + }); diff --git a/clients/client-inspector/endpoints.ts b/clients/client-inspector/endpoints.ts index 8d2ee66f7e929..b426e96bc28fe 100644 --- a/clients/client-inspector/endpoints.ts +++ b/clients/client-inspector/endpoints.ts @@ -1,210 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "inspector.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "inspector.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "inspector.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "inspector.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "inspector.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "inspector-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "inspector-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "inspector-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "inspector-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "inspector-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "inspector-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "inspector.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "inspector.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "inspector.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "inspector.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "inspector.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "inspector.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "inspector.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "inspector.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "inspector-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "inspector-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "inspector-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "inspector-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "inspector-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "inspector-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "inspector.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "inspector.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "inspector.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "inspector.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "inspector.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "inspector.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "inspector", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "inspector.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "inspector.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "inspector.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "inspector.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "inspector.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "inspector", + regionHash, + partitionHash, + }); diff --git a/clients/client-iot-1click-devices-service/endpoints.ts b/clients/client-iot-1click-devices-service/endpoints.ts index 0d1325e117b7d..62bfc81d1797f 100644 --- a/clients/client-iot-1click-devices-service/endpoints.ts +++ b/clients/client-iot-1click-devices-service/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "devices.iot1click.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "devices.iot1click.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "devices.iot1click.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "devices.iot1click.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "devices.iot1click.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "iot1click", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "devices.iot1click.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "devices.iot1click.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "devices.iot1click.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "devices.iot1click.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "devices.iot1click.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iot1click", + regionHash, + partitionHash, + }); diff --git a/clients/client-iot-1click-projects/endpoints.ts b/clients/client-iot-1click-projects/endpoints.ts index 7b00789268ee3..c0d8c0578fcb6 100644 --- a/clients/client-iot-1click-projects/endpoints.ts +++ b/clients/client-iot-1click-projects/endpoints.ts @@ -1,126 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "projects.iot1click.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "projects.iot1click.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "projects.iot1click.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "projects.iot1click.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "projects.iot1click.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "projects.iot1click.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "projects.iot1click.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "projects.iot1click.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "projects.iot1click.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "projects.iot1click.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "projects.iot1click.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "projects.iot1click.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "iot1click", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "projects.iot1click.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "projects.iot1click.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "projects.iot1click.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "projects.iot1click.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "projects.iot1click.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iot1click", + regionHash, + partitionHash, + }); diff --git a/clients/client-iot-data-plane/endpoints.ts b/clients/client-iot-data-plane/endpoints.ts index 7d18b6ba4fe41..4a8c354c9ecd4 100644 --- a/clients/client-iot-data-plane/endpoints.ts +++ b/clients/client-iot-data-plane/endpoints.ts @@ -1,291 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "data.iot.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "data.iot.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "data.iot.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "data.iot.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "data.iot.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "data.iot-fips.ca-central-1.amazonaws.com", + signingService: "iotdata", + }, + "fips-us-east-1": { + hostname: "data.iot-fips.us-east-1.amazonaws.com", + signingService: "iotdata", + }, + "fips-us-east-2": { + hostname: "data.iot-fips.us-east-2.amazonaws.com", + signingService: "iotdata", + }, + "fips-us-gov-east-1": { + hostname: "data.iot-fips.us-gov-east-1.amazonaws.com", + signingService: "iotdata", + }, + "fips-us-gov-west-1": { + hostname: "data.iot-fips.us-gov-west-1.amazonaws.com", + signingService: "iotdata", + }, + "fips-us-west-1": { + hostname: "data.iot-fips.us-west-1.amazonaws.com", + signingService: "iotdata", + }, + "fips-us-west-2": { + hostname: "data.iot-fips.us-west-2.amazonaws.com", + signingService: "iotdata", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "data.iot.ap-east-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "data.iot.ap-northeast-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "data.iot.ap-northeast-2.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "data.iot.ap-south-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "data.iot.ap-southeast-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "data.iot.ap-southeast-2.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "data.iot.ca-central-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "data.iot.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - signingService: "iotdata", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "data.iot.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingService: "iotdata", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "data.iot.eu-central-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "data.iot.eu-north-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "data.iot.eu-west-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "data.iot.eu-west-2.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "data.iot.eu-west-3.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "data.iot-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "data.iot-fips.us-east-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "data.iot-fips.us-east-2.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "data.iot-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "iotdata", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "data.iot-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "iotdata", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "data.iot-fips.us-west-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "data.iot-fips.us-west-2.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "data.iot.me-south-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "data.iot.sa-east-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "data.iot.us-east-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "data.iot.us-east-2.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "data.iot.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "iotdata", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "data.iot.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "iotdata", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "data.iot.us-west-1.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "data.iot.us-west-2.amazonaws.com", - partition: "aws", - signingService: "iotdata", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "iotdata", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - signingService: "iotdata", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - signingService: "iotdata", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "iotdata", - }; - } - } - return Promise.resolve({ signingService: "iotdata", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "data.iot.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "data.iot.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "data.iot.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "data.iot.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "data.iot.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iotdata", + regionHash, + partitionHash, + }); diff --git a/clients/client-iot-events-data/endpoints.ts b/clients/client-iot-events-data/endpoints.ts index cd00b6c780752..33d55daa8944c 100644 --- a/clients/client-iot-events-data/endpoints.ts +++ b/clients/client-iot-events-data/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "data.iotevents.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "data.iotevents.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "data.iotevents.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "data.iotevents.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "data.iotevents.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ioteventsdata", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "data.iotevents.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "data.iotevents.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "data.iotevents.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "data.iotevents.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "data.iotevents.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ioteventsdata", + regionHash, + partitionHash, + }); diff --git a/clients/client-iot-events/endpoints.ts b/clients/client-iot-events/endpoints.ts index b01ee4f29fd67..f6c686915a8e8 100644 --- a/clients/client-iot-events/endpoints.ts +++ b/clients/client-iot-events/endpoints.ts @@ -1,150 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "iotevents.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "iotevents.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "iotevents.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "iotevents.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "iotevents.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "iotevents.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "iotevents.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "iotevents.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "iotevents.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "iotevents.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "iotevents.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "iotevents.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "iotevents.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "iotevents.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "iotevents.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "iotevents.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "iotevents", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "iotevents.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "iotevents.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "iotevents.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "iotevents.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "iotevents.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iotevents", + regionHash, + partitionHash, + }); diff --git a/clients/client-iot-jobs-data-plane/endpoints.ts b/clients/client-iot-jobs-data-plane/endpoints.ts index 3db1632be75b7..b49b063d9e579 100644 --- a/clients/client-iot-jobs-data-plane/endpoints.ts +++ b/clients/client-iot-jobs-data-plane/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "data.jobs.iot.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "data.jobs.iot.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "data.jobs.iot.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "data.jobs.iot.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "data.jobs.iot.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "iot-jobs-data", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "data.jobs.iot.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "data.jobs.iot.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "data.jobs.iot.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "data.jobs.iot.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "data.jobs.iot.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iot-jobs-data", + regionHash, + partitionHash, + }); diff --git a/clients/client-iot-wireless/endpoints.ts b/clients/client-iot-wireless/endpoints.ts index ba9911eb22f2d..53a6339a6e1d6 100644 --- a/clients/client-iot-wireless/endpoints.ts +++ b/clients/client-iot-wireless/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "api.iotwireless.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "api.iotwireless.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "api.iotwireless.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "api.iotwireless.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "api.iotwireless.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "iotwireless", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "api.iotwireless.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "api.iotwireless.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "api.iotwireless.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "api.iotwireless.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "api.iotwireless.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iotwireless", + regionHash, + partitionHash, + }); diff --git a/clients/client-iot/endpoints.ts b/clients/client-iot/endpoints.ts index 4839f196a1aa7..aa0bb16ea6f98 100644 --- a/clients/client-iot/endpoints.ts +++ b/clients/client-iot/endpoints.ts @@ -1,291 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "iot.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "iot.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "iot.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "iot.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "iot.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "iot-fips.ca-central-1.amazonaws.com", + signingService: "execute-api", + }, + "fips-us-east-1": { + hostname: "iot-fips.us-east-1.amazonaws.com", + signingService: "execute-api", + }, + "fips-us-east-2": { + hostname: "iot-fips.us-east-2.amazonaws.com", + signingService: "execute-api", + }, + "fips-us-gov-east-1": { + hostname: "iot-fips.us-gov-east-1.amazonaws.com", + signingService: "execute-api", + }, + "fips-us-gov-west-1": { + hostname: "iot-fips.us-gov-west-1.amazonaws.com", + signingService: "execute-api", + }, + "fips-us-west-1": { + hostname: "iot-fips.us-west-1.amazonaws.com", + signingService: "execute-api", + }, + "fips-us-west-2": { + hostname: "iot-fips.us-west-2.amazonaws.com", + signingService: "execute-api", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "iot.ap-east-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "iot.ap-northeast-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "iot.ap-northeast-2.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "iot.ap-south-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "iot.ap-southeast-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "iot.ap-southeast-2.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "iot.ca-central-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "iot.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - signingService: "execute-api", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "iot.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingService: "execute-api", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "iot.eu-central-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "iot.eu-north-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "iot.eu-west-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "iot.eu-west-2.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "iot.eu-west-3.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "iot-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "iot-fips.us-east-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "iot-fips.us-east-2.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "iot-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "execute-api", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "iot-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "execute-api", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "iot-fips.us-west-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "iot-fips.us-west-2.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "iot.me-south-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "iot.sa-east-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "iot.us-east-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "iot.us-east-2.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "iot.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "execute-api", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "iot.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "execute-api", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "iot.us-west-1.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "iot.us-west-2.amazonaws.com", - partition: "aws", - signingService: "execute-api", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "execute-api", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - signingService: "execute-api", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - signingService: "execute-api", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "execute-api", - }; - } - } - return Promise.resolve({ signingService: "execute-api", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "iot.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "iot.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "iot.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "iot.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "iot.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "execute-api", + regionHash, + partitionHash, + }); diff --git a/clients/client-iotanalytics/endpoints.ts b/clients/client-iotanalytics/endpoints.ts index d24880dfbc98e..7d1ec3654b921 100644 --- a/clients/client-iotanalytics/endpoints.ts +++ b/clients/client-iotanalytics/endpoints.ts @@ -1,132 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "iotanalytics.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "iotanalytics.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "iotanalytics.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "iotanalytics.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "iotanalytics.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "iotanalytics.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "iotanalytics.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "iotanalytics.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "iotanalytics.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "iotanalytics.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "iotanalytics.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "iotanalytics.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "iotanalytics.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "iotanalytics", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "iotanalytics.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "iotanalytics.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "iotanalytics.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "iotanalytics.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "iotanalytics.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iotanalytics", + regionHash, + partitionHash, + }); diff --git a/clients/client-iotdeviceadvisor/endpoints.ts b/clients/client-iotdeviceadvisor/endpoints.ts index 18f1ed7130aac..dbe3c9ea6fed4 100644 --- a/clients/client-iotdeviceadvisor/endpoints.ts +++ b/clients/client-iotdeviceadvisor/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "api.iotdeviceadvisor.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "api.iotdeviceadvisor.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "api.iotdeviceadvisor.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "api.iotdeviceadvisor.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "api.iotdeviceadvisor.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "iotdeviceadvisor", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "api.iotdeviceadvisor.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "api.iotdeviceadvisor.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "api.iotdeviceadvisor.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "api.iotdeviceadvisor.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "api.iotdeviceadvisor.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iotdeviceadvisor", + regionHash, + partitionHash, + }); diff --git a/clients/client-iotfleethub/endpoints.ts b/clients/client-iotfleethub/endpoints.ts index a45062657cff5..c7157d05a419d 100644 --- a/clients/client-iotfleethub/endpoints.ts +++ b/clients/client-iotfleethub/endpoints.ts @@ -1,190 +1,78 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "api.fleethub.iot.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "api.fleethub.iot.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "api.fleethub.iot.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "api.fleethub.iot.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "api.fleethub.iot.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "api.fleethub.iot-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "api.fleethub.iot-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "api.fleethub.iot-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-2": { + hostname: "api.fleethub.iot-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "api.fleethub.iot.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "api.fleethub.iot.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "api.fleethub.iot.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "api.fleethub.iot.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "api.fleethub.iot.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "api.fleethub.iot.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "api.fleethub.iot.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "api.fleethub.iot.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "api.fleethub.iot.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "api.fleethub.iot.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "api.fleethub.iot-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "api.fleethub.iot-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "api.fleethub.iot-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "api.fleethub.iot-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "api.fleethub.iot.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "api.fleethub.iot.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "api.fleethub.iot.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "iotfleethub", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "api.fleethub.iot.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "api.fleethub.iot.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "api.fleethub.iot.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "api.fleethub.iot.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "api.fleethub.iot.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iotfleethub", + regionHash, + partitionHash, + }); diff --git a/clients/client-iotsecuretunneling/endpoints.ts b/clients/client-iotsecuretunneling/endpoints.ts index a718d816391b6..acc9a62e8a4a8 100644 --- a/clients/client-iotsecuretunneling/endpoints.ts +++ b/clients/client-iotsecuretunneling/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "api.tunneling.iot.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "api.tunneling.iot.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "api.tunneling.iot.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "api.tunneling.iot.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "api.tunneling.iot.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "iotsecuredtunneling", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "api.tunneling.iot.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "api.tunneling.iot.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "api.tunneling.iot.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "api.tunneling.iot.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "api.tunneling.iot.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iotsecuredtunneling", + regionHash, + partitionHash, + }); diff --git a/clients/client-iotsitewise/endpoints.ts b/clients/client-iotsitewise/endpoints.ts index dd9726bb80d3e..16142c78ac65a 100644 --- a/clients/client-iotsitewise/endpoints.ts +++ b/clients/client-iotsitewise/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "iotsitewise.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "iotsitewise.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "iotsitewise.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "iotsitewise.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "iotsitewise.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "iotsitewise", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "iotsitewise.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "iotsitewise.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "iotsitewise.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "iotsitewise.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "iotsitewise.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iotsitewise", + regionHash, + partitionHash, + }); diff --git a/clients/client-iotthingsgraph/endpoints.ts b/clients/client-iotthingsgraph/endpoints.ts index cef99fe41ed0d..9fc0e4e32a10b 100644 --- a/clients/client-iotthingsgraph/endpoints.ts +++ b/clients/client-iotthingsgraph/endpoints.ts @@ -1,128 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "iotthingsgraph.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "iotthingsgraph.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "iotthingsgraph.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "iotthingsgraph.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "iotthingsgraph.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "iotthingsgraph.ap-northeast-1.amazonaws.com", - partition: "aws", - signingService: "iotthingsgraph", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "iotthingsgraph.ap-northeast-2.amazonaws.com", - partition: "aws", - signingService: "iotthingsgraph", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "iotthingsgraph.ap-southeast-2.amazonaws.com", - partition: "aws", - signingService: "iotthingsgraph", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "iotthingsgraph.eu-west-1.amazonaws.com", - partition: "aws", - signingService: "iotthingsgraph", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "iotthingsgraph.us-east-1.amazonaws.com", - partition: "aws", - signingService: "iotthingsgraph", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "iotthingsgraph.us-west-2.amazonaws.com", - partition: "aws", - signingService: "iotthingsgraph", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "iotthingsgraph", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "iotthingsgraph", - }; - } - } - return Promise.resolve({ signingService: "iotthingsgraph", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "iotthingsgraph.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "iotthingsgraph.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "iotthingsgraph.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "iotthingsgraph.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "iotthingsgraph.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "iotthingsgraph", + regionHash, + partitionHash, + }); diff --git a/clients/client-ivs/endpoints.ts b/clients/client-ivs/endpoints.ts index d5e0dc7b33819..94d477a2464c3 100644 --- a/clients/client-ivs/endpoints.ts +++ b/clients/client-ivs/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "ivs.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "ivs.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "ivs.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "ivs.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "ivs.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ivs", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "ivs.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "ivs.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "ivs.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "ivs.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "ivs.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ivs", + regionHash, + partitionHash, + }); diff --git a/clients/client-kafka/endpoints.ts b/clients/client-kafka/endpoints.ts index 2ba0e7acc3336..b36efc3f3b7f9 100644 --- a/clients/client-kafka/endpoints.ts +++ b/clients/client-kafka/endpoints.ts @@ -1,222 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "kafka.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "kafka.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "kafka.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "kafka.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "kafka.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "kafka.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "kafka.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "kafka.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "kafka.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "kafka.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "kafka.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "kafka.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "kafka.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "kafka.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "kafka.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "kafka.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "kafka.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "kafka.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "kafka.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "kafka.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "kafka.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "kafka.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "kafka.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "kafka.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "kafka.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "kafka.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "kafka.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "kafka.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "kafka", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "kafka.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "kafka.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "kafka.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "kafka.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "kafka.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "kafka", + regionHash, + partitionHash, + }); diff --git a/clients/client-kendra/endpoints.ts b/clients/client-kendra/endpoints.ts index 466ea8ff91261..4299dd6fdceee 100644 --- a/clients/client-kendra/endpoints.ts +++ b/clients/client-kendra/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "kendra.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "kendra.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "kendra.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "kendra.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "kendra.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "kendra", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "kendra.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "kendra.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "kendra.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "kendra.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "kendra.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "kendra", + regionHash, + partitionHash, + }); diff --git a/clients/client-kinesis-analytics-v2/endpoints.ts b/clients/client-kinesis-analytics-v2/endpoints.ts index e76ecf99c8d22..860cf66c0df44 100644 --- a/clients/client-kinesis-analytics-v2/endpoints.ts +++ b/clients/client-kinesis-analytics-v2/endpoints.ts @@ -1,222 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "kinesisanalytics.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "kinesisanalytics.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "kinesisanalytics.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "kinesisanalytics.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "kinesisanalytics.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "kinesisanalytics.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "kinesisanalytics.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "kinesisanalytics.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "kinesisanalytics.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "kinesisanalytics.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "kinesisanalytics.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "kinesisanalytics.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "kinesisanalytics.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "kinesisanalytics.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "kinesisanalytics.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "kinesisanalytics.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "kinesisanalytics.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "kinesisanalytics.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "kinesisanalytics.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "kinesisanalytics.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "kinesisanalytics.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "kinesisanalytics.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "kinesisanalytics.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "kinesisanalytics.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "kinesisanalytics.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "kinesisanalytics.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "kinesisanalytics.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "kinesisanalytics.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "kinesisanalytics", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "kinesisanalytics.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "kinesisanalytics.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "kinesisanalytics.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "kinesisanalytics.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "kinesisanalytics.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "kinesisanalytics", + regionHash, + partitionHash, + }); diff --git a/clients/client-kinesis-analytics/endpoints.ts b/clients/client-kinesis-analytics/endpoints.ts index e76ecf99c8d22..860cf66c0df44 100644 --- a/clients/client-kinesis-analytics/endpoints.ts +++ b/clients/client-kinesis-analytics/endpoints.ts @@ -1,222 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "kinesisanalytics.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "kinesisanalytics.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "kinesisanalytics.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "kinesisanalytics.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "kinesisanalytics.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "kinesisanalytics.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "kinesisanalytics.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "kinesisanalytics.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "kinesisanalytics.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "kinesisanalytics.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "kinesisanalytics.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "kinesisanalytics.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "kinesisanalytics.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "kinesisanalytics.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "kinesisanalytics.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "kinesisanalytics.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "kinesisanalytics.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "kinesisanalytics.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "kinesisanalytics.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "kinesisanalytics.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "kinesisanalytics.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "kinesisanalytics.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "kinesisanalytics.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "kinesisanalytics.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "kinesisanalytics.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "kinesisanalytics.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "kinesisanalytics.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "kinesisanalytics.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "kinesisanalytics", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "kinesisanalytics.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "kinesisanalytics.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "kinesisanalytics.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "kinesisanalytics.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "kinesisanalytics.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "kinesisanalytics", + regionHash, + partitionHash, + }); diff --git a/clients/client-kinesis-video-archived-media/endpoints.ts b/clients/client-kinesis-video-archived-media/endpoints.ts index 1c1596a6250b3..478b9474687b2 100644 --- a/clients/client-kinesis-video-archived-media/endpoints.ts +++ b/clients/client-kinesis-video-archived-media/endpoints.ts @@ -1,174 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "kinesisvideo.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "kinesisvideo.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "kinesisvideo.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "kinesisvideo.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "kinesisvideo.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "kinesisvideo.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "kinesisvideo.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "kinesisvideo.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "kinesisvideo.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "kinesisvideo.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "kinesisvideo.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "kinesisvideo.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "kinesisvideo.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "kinesisvideo.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "kinesisvideo.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "kinesisvideo.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "kinesisvideo.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "kinesisvideo.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "kinesisvideo.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "kinesisvideo.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "kinesisvideo", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "kinesisvideo.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "kinesisvideo.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "kinesisvideo.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "kinesisvideo.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "kinesisvideo.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "kinesisvideo", + regionHash, + partitionHash, + }); diff --git a/clients/client-kinesis-video-media/endpoints.ts b/clients/client-kinesis-video-media/endpoints.ts index 1c1596a6250b3..478b9474687b2 100644 --- a/clients/client-kinesis-video-media/endpoints.ts +++ b/clients/client-kinesis-video-media/endpoints.ts @@ -1,174 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "kinesisvideo.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "kinesisvideo.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "kinesisvideo.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "kinesisvideo.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "kinesisvideo.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "kinesisvideo.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "kinesisvideo.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "kinesisvideo.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "kinesisvideo.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "kinesisvideo.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "kinesisvideo.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "kinesisvideo.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "kinesisvideo.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "kinesisvideo.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "kinesisvideo.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "kinesisvideo.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "kinesisvideo.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "kinesisvideo.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "kinesisvideo.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "kinesisvideo.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "kinesisvideo", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "kinesisvideo.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "kinesisvideo.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "kinesisvideo.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "kinesisvideo.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "kinesisvideo.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "kinesisvideo", + regionHash, + partitionHash, + }); diff --git a/clients/client-kinesis-video-signaling/endpoints.ts b/clients/client-kinesis-video-signaling/endpoints.ts index 1c1596a6250b3..478b9474687b2 100644 --- a/clients/client-kinesis-video-signaling/endpoints.ts +++ b/clients/client-kinesis-video-signaling/endpoints.ts @@ -1,174 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "kinesisvideo.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "kinesisvideo.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "kinesisvideo.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "kinesisvideo.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "kinesisvideo.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "kinesisvideo.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "kinesisvideo.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "kinesisvideo.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "kinesisvideo.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "kinesisvideo.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "kinesisvideo.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "kinesisvideo.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "kinesisvideo.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "kinesisvideo.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "kinesisvideo.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "kinesisvideo.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "kinesisvideo.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "kinesisvideo.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "kinesisvideo.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "kinesisvideo.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "kinesisvideo", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "kinesisvideo.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "kinesisvideo.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "kinesisvideo.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "kinesisvideo.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "kinesisvideo.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "kinesisvideo", + regionHash, + partitionHash, + }); diff --git a/clients/client-kinesis-video/endpoints.ts b/clients/client-kinesis-video/endpoints.ts index 1c1596a6250b3..478b9474687b2 100644 --- a/clients/client-kinesis-video/endpoints.ts +++ b/clients/client-kinesis-video/endpoints.ts @@ -1,174 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "kinesisvideo.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "kinesisvideo.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "kinesisvideo.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "kinesisvideo.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "kinesisvideo.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "kinesisvideo.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "kinesisvideo.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "kinesisvideo.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "kinesisvideo.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "kinesisvideo.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "kinesisvideo.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "kinesisvideo.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "kinesisvideo.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "kinesisvideo.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "kinesisvideo.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "kinesisvideo.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "kinesisvideo.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "kinesisvideo.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "kinesisvideo.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "kinesisvideo.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "kinesisvideo", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "kinesisvideo.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "kinesisvideo.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "kinesisvideo.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "kinesisvideo.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "kinesisvideo.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "kinesisvideo", + regionHash, + partitionHash, + }); diff --git a/clients/client-kinesis/endpoints.ts b/clients/client-kinesis/endpoints.ts index 0e68788f5fe53..90dd11f18a4dd 100644 --- a/clients/client-kinesis/endpoints.ts +++ b/clients/client-kinesis/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "kinesis.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "kinesis.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "kinesis.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "kinesis.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "kinesis.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "kinesis-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "kinesis-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "kinesis-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "kinesis-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "kinesis.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "kinesis.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "kinesis.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "kinesis.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "kinesis.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "kinesis.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "kinesis.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "kinesis.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "kinesis.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "kinesis.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "kinesis.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "kinesis.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "kinesis.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "kinesis.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "kinesis.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "kinesis.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "kinesis.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "kinesis.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "kinesis.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "kinesis-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "kinesis-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "kinesis-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "kinesis-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "kinesis.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "kinesis.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "kinesis.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "kinesis.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "kinesis.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "kinesis.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "kinesis.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "kinesis.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "kinesis.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "kinesis.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "kinesis", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "kinesis.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "kinesis.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "kinesis.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "kinesis.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "kinesis.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "kinesis", + regionHash, + partitionHash, + }); diff --git a/clients/client-kms/endpoints.ts b/clients/client-kms/endpoints.ts index ab6747bbfd62b..883d42fb022be 100644 --- a/clients/client-kms/endpoints.ts +++ b/clients/client-kms/endpoints.ts @@ -1,253 +1,62 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "kms.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "kms.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "kms.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "kms.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "kms.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + ProdFips: { + hostname: "kms-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ProdFips": - regionInfo = { - hostname: "kms-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "af-south-1": - regionInfo = { - hostname: "kms.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "kms.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "kms.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "kms.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "kms.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "kms.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "kms.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "kms.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "kms.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "kms.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "kms.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "kms.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "kms.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "kms.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "kms.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "kms.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "kms.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "kms.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "kms.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "kms.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "kms.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "kms.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "kms.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "kms.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "kms.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "kms.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "kms.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "kms", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "kms.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "kms.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["ProdFips", "us-iso-east-1"], + hostname: "kms.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["ProdFips", "us-isob-east-1"], + hostname: "kms.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["ProdFips", "us-gov-east-1", "us-gov-west-1"], + hostname: "kms.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "kms", + regionHash, + partitionHash, + }); diff --git a/clients/client-lakeformation/endpoints.ts b/clients/client-lakeformation/endpoints.ts index 9051d8a2508c5..a77fd2acdc8f3 100644 --- a/clients/client-lakeformation/endpoints.ts +++ b/clients/client-lakeformation/endpoints.ts @@ -1,257 +1,82 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "lakeformation.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "lakeformation.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "lakeformation.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "lakeformation.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "lakeformation.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "lakeformation-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "lakeformation-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-west-1": { + hostname: "lakeformation-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "lakeformation-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "lakeformation-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "lakeformation.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "lakeformation.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "lakeformation.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "lakeformation.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "lakeformation.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "lakeformation.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "lakeformation.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "lakeformation.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "lakeformation.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "lakeformation.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "lakeformation.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "lakeformation.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "lakeformation.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "lakeformation.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "lakeformation.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "lakeformation.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "lakeformation-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "lakeformation-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "lakeformation-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "lakeformation-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "lakeformation-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "lakeformation.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "lakeformation.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "lakeformation.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "lakeformation.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "lakeformation.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "lakeformation.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "lakeformation.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "lakeformation", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "lakeformation.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "lakeformation.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "lakeformation.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "lakeformation.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "lakeformation.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "lakeformation", + regionHash, + partitionHash, + }); diff --git a/clients/client-lambda/endpoints.ts b/clients/client-lambda/endpoints.ts index 875da9b300513..c53c1e6469018 100644 --- a/clients/client-lambda/endpoints.ts +++ b/clients/client-lambda/endpoints.ts @@ -1,288 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "lambda.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "lambda.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "lambda.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "lambda.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "lambda.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "lambda-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "lambda-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "lambda-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "lambda-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "lambda-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "lambda-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "lambda.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "lambda.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "lambda.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "lambda.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "lambda.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "lambda.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "lambda.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "lambda.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "lambda.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "lambda.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "lambda.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "lambda.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "lambda.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "lambda.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "lambda.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "lambda.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "lambda.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "lambda-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "lambda-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "lambda-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "lambda-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "lambda-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "lambda-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "lambda.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "lambda.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "lambda.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "lambda.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "lambda.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "lambda.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "lambda.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "lambda.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "lambda.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "lambda.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "lambda", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "lambda.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "lambda.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "lambda.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "lambda.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "lambda.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "lambda", + regionHash, + partitionHash, + }); diff --git a/clients/client-lex-model-building-service/endpoints.ts b/clients/client-lex-model-building-service/endpoints.ts index 05bd965f863f2..7b340e74f1468 100644 --- a/clients/client-lex-model-building-service/endpoints.ts +++ b/clients/client-lex-model-building-service/endpoints.ts @@ -1,171 +1,72 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "models.lex.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "models.lex.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "models.lex.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "models.lex.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "models.lex.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "models-fips.lex.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-gov-west-1-fips": { + hostname: "models-fips.lex.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-2-fips": { + hostname: "models-fips.lex.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "models.lex.ap-northeast-1.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "models.lex.ap-southeast-1.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "models.lex.ap-southeast-2.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "models.lex.eu-central-1.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "models.lex.eu-west-1.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "models.lex.eu-west-2.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "models.lex.us-east-1.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "models-fips.lex.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "models.lex.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "lex", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "models-fips.lex.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "models.lex.us-west-2.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "models-fips.lex.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "lex", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - signingService: "lex", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "lex", - }; - } - } - return Promise.resolve({ signingService: "lex", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-west-1", + "us-west-2", + "us-west-2-fips", + ], + hostname: "models.lex.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "models.lex.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "models.lex.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "models.lex.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "models.lex.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "lex", + regionHash, + partitionHash, + }); diff --git a/clients/client-lex-models-v2/endpoints.ts b/clients/client-lex-models-v2/endpoints.ts index 7a666a2575d64..2111d4a1944aa 100644 --- a/clients/client-lex-models-v2/endpoints.ts +++ b/clients/client-lex-models-v2/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "models-v2-lex.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "models-v2-lex.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "models-v2-lex.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "models-v2-lex.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "models-v2-lex.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "lex", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "models-v2-lex.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "models-v2-lex.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "models-v2-lex.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "models-v2-lex.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "models-v2-lex.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "lex", + regionHash, + partitionHash, + }); diff --git a/clients/client-lex-runtime-service/endpoints.ts b/clients/client-lex-runtime-service/endpoints.ts index 5dab00497a003..e1acd3157d8de 100644 --- a/clients/client-lex-runtime-service/endpoints.ts +++ b/clients/client-lex-runtime-service/endpoints.ts @@ -1,171 +1,72 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "runtime.lex.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "runtime.lex.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "runtime.lex.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "runtime.lex.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "runtime.lex.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "runtime-fips.lex.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-gov-west-1-fips": { + hostname: "runtime-fips.lex.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-2-fips": { + hostname: "runtime-fips.lex.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "runtime.lex.ap-northeast-1.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "runtime.lex.ap-southeast-1.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "runtime.lex.ap-southeast-2.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "runtime.lex.eu-central-1.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "runtime.lex.eu-west-1.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "runtime.lex.eu-west-2.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "runtime.lex.us-east-1.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "runtime-fips.lex.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "runtime.lex.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "lex", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "runtime-fips.lex.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "runtime.lex.us-west-2.amazonaws.com", - partition: "aws", - signingService: "lex", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "runtime-fips.lex.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "lex", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - signingService: "lex", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "lex", - }; - } - } - return Promise.resolve({ signingService: "lex", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-west-1", + "us-west-2", + "us-west-2-fips", + ], + hostname: "runtime.lex.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "runtime.lex.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "runtime.lex.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "runtime.lex.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "runtime.lex.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "lex", + regionHash, + partitionHash, + }); diff --git a/clients/client-lex-runtime-v2/endpoints.ts b/clients/client-lex-runtime-v2/endpoints.ts index 4313cab6beef6..b090f9293f6c4 100644 --- a/clients/client-lex-runtime-v2/endpoints.ts +++ b/clients/client-lex-runtime-v2/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "runtime-v2-lex.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "runtime-v2-lex.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "runtime-v2-lex.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "runtime-v2-lex.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "runtime-v2-lex.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "lex", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "runtime-v2-lex.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "runtime-v2-lex.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "runtime-v2-lex.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "runtime-v2-lex.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "runtime-v2-lex.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "lex", + regionHash, + partitionHash, + }); diff --git a/clients/client-license-manager/endpoints.ts b/clients/client-license-manager/endpoints.ts index 1f39c8554d7b5..8f1c0d1deb172 100644 --- a/clients/client-license-manager/endpoints.ts +++ b/clients/client-license-manager/endpoints.ts @@ -1,288 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "license-manager.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "license-manager.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "license-manager.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "license-manager.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "license-manager.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "license-manager-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "license-manager-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "license-manager-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "license-manager-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "license-manager-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "license-manager-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "license-manager.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "license-manager.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "license-manager.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "license-manager.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "license-manager.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "license-manager.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "license-manager.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "license-manager.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "license-manager.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "license-manager.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "license-manager.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "license-manager.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "license-manager.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "license-manager.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "license-manager.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "license-manager.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "license-manager.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "license-manager-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "license-manager-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "license-manager-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "license-manager-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "license-manager-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "license-manager-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "license-manager.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "license-manager.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "license-manager.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "license-manager.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "license-manager.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "license-manager.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "license-manager.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "license-manager.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "license-manager.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "license-manager.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "license-manager", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "license-manager.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "license-manager.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "license-manager.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "license-manager.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "license-manager.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "license-manager", + regionHash, + partitionHash, + }); diff --git a/clients/client-lightsail/endpoints.ts b/clients/client-lightsail/endpoints.ts index a4b454fac773d..4c045f905210c 100644 --- a/clients/client-lightsail/endpoints.ts +++ b/clients/client-lightsail/endpoints.ts @@ -1,168 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "lightsail.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "lightsail.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "lightsail.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "lightsail.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "lightsail.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "lightsail.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "lightsail.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "lightsail.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "lightsail.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "lightsail.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "lightsail.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "lightsail.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "lightsail.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "lightsail.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "lightsail.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "lightsail.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "lightsail.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "lightsail.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "lightsail.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "lightsail", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "lightsail.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "lightsail.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "lightsail.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "lightsail.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "lightsail.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "lightsail", + regionHash, + partitionHash, + }); diff --git a/clients/client-location/endpoints.ts b/clients/client-location/endpoints.ts index 01549c2ffe059..d6079bc819730 100644 --- a/clients/client-location/endpoints.ts +++ b/clients/client-location/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "geo.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "geo.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "geo.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "geo.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "geo.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "geo", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "geo.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "geo.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "geo.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "geo.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "geo.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "geo", + regionHash, + partitionHash, + }); diff --git a/clients/client-lookoutequipment/endpoints.ts b/clients/client-lookoutequipment/endpoints.ts index aa1b326442bf0..a98647d2e727d 100644 --- a/clients/client-lookoutequipment/endpoints.ts +++ b/clients/client-lookoutequipment/endpoints.ts @@ -1,102 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "lookoutequipment.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "lookoutequipment.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "lookoutequipment.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "lookoutequipment.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "lookoutequipment.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-2": - regionInfo = { - hostname: "lookoutequipment.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "lookoutequipment.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "lookoutequipment.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "lookoutequipment", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "lookoutequipment.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "lookoutequipment.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "lookoutequipment.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "lookoutequipment.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "lookoutequipment.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "lookoutequipment", + regionHash, + partitionHash, + }); diff --git a/clients/client-lookoutmetrics/endpoints.ts b/clients/client-lookoutmetrics/endpoints.ts index 8da8676dbefed..a7acfe25f272d 100644 --- a/clients/client-lookoutmetrics/endpoints.ts +++ b/clients/client-lookoutmetrics/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "lookoutmetrics.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "lookoutmetrics.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "lookoutmetrics.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "lookoutmetrics.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "lookoutmetrics.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "lookoutmetrics", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "lookoutmetrics.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "lookoutmetrics.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "lookoutmetrics.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "lookoutmetrics.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "lookoutmetrics.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "lookoutmetrics", + regionHash, + partitionHash, + }); diff --git a/clients/client-lookoutvision/endpoints.ts b/clients/client-lookoutvision/endpoints.ts index 69a0da4930fc7..cc0284d635573 100644 --- a/clients/client-lookoutvision/endpoints.ts +++ b/clients/client-lookoutvision/endpoints.ts @@ -1,126 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "lookoutvision.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "lookoutvision.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "lookoutvision.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "lookoutvision.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "lookoutvision.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "lookoutvision.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "lookoutvision.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "lookoutvision.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "lookoutvision.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "lookoutvision.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "lookoutvision.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "lookoutvision.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "lookoutvision", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "lookoutvision.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "lookoutvision.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "lookoutvision.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "lookoutvision.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "lookoutvision.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "lookoutvision", + regionHash, + partitionHash, + }); diff --git a/clients/client-machine-learning/endpoints.ts b/clients/client-machine-learning/endpoints.ts index e5c2f754f9c5e..daf4b7ee816a0 100644 --- a/clients/client-machine-learning/endpoints.ts +++ b/clients/client-machine-learning/endpoints.ts @@ -1,96 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "machinelearning.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "machinelearning.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "machinelearning.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "machinelearning.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "machinelearning.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "eu-west-1": - regionInfo = { - hostname: "machinelearning.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "machinelearning.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "machinelearning", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "machinelearning.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "machinelearning.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "machinelearning.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "machinelearning.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "machinelearning.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "machinelearning", + regionHash, + partitionHash, + }); diff --git a/clients/client-macie/endpoints.ts b/clients/client-macie/endpoints.ts index 01b884944b47b..e50c635367aeb 100644 --- a/clients/client-macie/endpoints.ts +++ b/clients/client-macie/endpoints.ts @@ -1,110 +1,68 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "macie.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "macie.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "macie.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "macie.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "macie.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "macie-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-west-2": { + hostname: "macie-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "fips-us-east-1": - regionInfo = { - hostname: "macie-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "macie-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "macie.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "macie.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "macie", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "macie.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "macie.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "macie.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "macie.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "macie.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "macie", + regionHash, + partitionHash, + }); diff --git a/clients/client-macie2/endpoints.ts b/clients/client-macie2/endpoints.ts index cafa2e465813d..8dd7fea7ee330 100644 --- a/clients/client-macie2/endpoints.ts +++ b/clients/client-macie2/endpoints.ts @@ -1,238 +1,78 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "macie2.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "macie2.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "macie2.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "macie2.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "macie2.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "macie2-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "macie2-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "macie2-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "macie2-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "macie2.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "macie2.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "macie2.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "macie2.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "macie2.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "macie2.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "macie2.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "macie2.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "macie2.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "macie2.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "macie2.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "macie2.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "macie2.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "macie2.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "macie2.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "macie2-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "macie2-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "macie2-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "macie2-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "macie2.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "macie2.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "macie2.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "macie2.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "macie2.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "macie2.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "macie2", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "macie2.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "macie2.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "macie2.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "macie2.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "macie2.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "macie2", + regionHash, + partitionHash, + }); diff --git a/clients/client-managedblockchain/endpoints.ts b/clients/client-managedblockchain/endpoints.ts index 060340b4c53f6..be7b604fcbf22 100644 --- a/clients/client-managedblockchain/endpoints.ts +++ b/clients/client-managedblockchain/endpoints.ts @@ -1,120 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "managedblockchain.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "managedblockchain.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "managedblockchain.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "managedblockchain.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "managedblockchain.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "managedblockchain.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "managedblockchain.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "managedblockchain.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "managedblockchain.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "managedblockchain.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "managedblockchain.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "managedblockchain", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "managedblockchain.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "managedblockchain.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "managedblockchain.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "managedblockchain.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "managedblockchain.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "managedblockchain", + regionHash, + partitionHash, + }); diff --git a/clients/client-marketplace-catalog/endpoints.ts b/clients/client-marketplace-catalog/endpoints.ts index 7a31b574f440a..ed16b797def77 100644 --- a/clients/client-marketplace-catalog/endpoints.ts +++ b/clients/client-marketplace-catalog/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "catalog.marketplace.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "catalog.marketplace.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "catalog.marketplace.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "catalog.marketplace.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "catalog.marketplace.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "aws-marketplace", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "catalog.marketplace.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "catalog.marketplace.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "catalog.marketplace.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "catalog.marketplace.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "catalog.marketplace.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "aws-marketplace", + regionHash, + partitionHash, + }); diff --git a/clients/client-marketplace-commerce-analytics/endpoints.ts b/clients/client-marketplace-commerce-analytics/endpoints.ts index 13c11c75085bf..732a08c9614f8 100644 --- a/clients/client-marketplace-commerce-analytics/endpoints.ts +++ b/clients/client-marketplace-commerce-analytics/endpoints.ts @@ -1,90 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "marketplacecommerceanalytics.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "marketplacecommerceanalytics.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "marketplacecommerceanalytics.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "marketplacecommerceanalytics.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "marketplacecommerceanalytics.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "us-east-1": - regionInfo = { - hostname: "marketplacecommerceanalytics.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "marketplacecommerceanalytics", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "marketplacecommerceanalytics.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "marketplacecommerceanalytics.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "marketplacecommerceanalytics.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "marketplacecommerceanalytics.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "marketplacecommerceanalytics.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "marketplacecommerceanalytics", + regionHash, + partitionHash, + }); diff --git a/clients/client-marketplace-entitlement-service/endpoints.ts b/clients/client-marketplace-entitlement-service/endpoints.ts index 6dd5e3e46eda6..3340f837dc3de 100644 --- a/clients/client-marketplace-entitlement-service/endpoints.ts +++ b/clients/client-marketplace-entitlement-service/endpoints.ts @@ -1,93 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "entitlement.marketplace.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "entitlement.marketplace.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "entitlement.marketplace.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "entitlement.marketplace.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "entitlement.marketplace.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "us-east-1": - regionInfo = { - hostname: "entitlement.marketplace.us-east-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "aws-marketplace", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "aws-marketplace", - }; - } - } - return Promise.resolve({ signingService: "aws-marketplace", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "entitlement.marketplace.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "entitlement.marketplace.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "entitlement.marketplace.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "entitlement.marketplace.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "entitlement.marketplace.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "aws-marketplace", + regionHash, + partitionHash, + }); diff --git a/clients/client-marketplace-metering/endpoints.ts b/clients/client-marketplace-metering/endpoints.ts index 81286b868533e..e7215ee4f98a2 100644 --- a/clients/client-marketplace-metering/endpoints.ts +++ b/clients/client-marketplace-metering/endpoints.ts @@ -1,248 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "metering.marketplace.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "metering.marketplace.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "metering.marketplace.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "metering.marketplace.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "metering.marketplace.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "metering.marketplace.af-south-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "metering.marketplace.ap-east-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "metering.marketplace.ap-northeast-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "metering.marketplace.ap-northeast-2.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "metering.marketplace.ap-northeast-3.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "metering.marketplace.ap-south-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "metering.marketplace.ap-southeast-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "metering.marketplace.ap-southeast-2.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "metering.marketplace.ca-central-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "metering.marketplace.eu-central-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "metering.marketplace.eu-north-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "metering.marketplace.eu-south-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "metering.marketplace.eu-west-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "metering.marketplace.eu-west-2.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "metering.marketplace.eu-west-3.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "metering.marketplace.me-south-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "metering.marketplace.sa-east-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "metering.marketplace.us-east-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "metering.marketplace.us-east-2.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "metering.marketplace.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "aws-marketplace", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "metering.marketplace.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingService: "aws-marketplace", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "metering.marketplace.us-west-1.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "metering.marketplace.us-west-2.amazonaws.com", - partition: "aws", - signingService: "aws-marketplace", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "aws-marketplace", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - signingService: "aws-marketplace", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "aws-marketplace", - }; - } - } - return Promise.resolve({ signingService: "aws-marketplace", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "metering.marketplace.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "metering.marketplace.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "metering.marketplace.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "metering.marketplace.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "metering.marketplace.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "aws-marketplace", + regionHash, + partitionHash, + }); diff --git a/clients/client-mediaconnect/endpoints.ts b/clients/client-mediaconnect/endpoints.ts index 636f7b455e078..0939445cf2cba 100644 --- a/clients/client-mediaconnect/endpoints.ts +++ b/clients/client-mediaconnect/endpoints.ts @@ -1,180 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "mediaconnect.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "mediaconnect.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "mediaconnect.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "mediaconnect.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "mediaconnect.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "mediaconnect.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "mediaconnect.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "mediaconnect.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "mediaconnect.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "mediaconnect.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "mediaconnect.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "mediaconnect.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "mediaconnect.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "mediaconnect.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "mediaconnect.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "mediaconnect.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "mediaconnect.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "mediaconnect.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "mediaconnect.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "mediaconnect.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "mediaconnect.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "mediaconnect", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "mediaconnect.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "mediaconnect.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "mediaconnect.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "mediaconnect.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "mediaconnect.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mediaconnect", + regionHash, + partitionHash, + }); diff --git a/clients/client-mediaconvert/endpoints.ts b/clients/client-mediaconvert/endpoints.ts index b42af414f4a86..352c81c74bb1c 100644 --- a/clients/client-mediaconvert/endpoints.ts +++ b/clients/client-mediaconvert/endpoints.ts @@ -1,229 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "mediaconvert.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "mediaconvert.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "mediaconvert.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "mediaconvert.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "mediaconvert.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "cn-northwest-1": { + hostname: "subscribe.mediaconvert.cn-northwest-1.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "fips-ca-central-1": { + hostname: "mediaconvert-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "mediaconvert-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "mediaconvert-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "mediaconvert-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "mediaconvert-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-west-1": { + hostname: "mediaconvert.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "mediaconvert.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "mediaconvert.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "mediaconvert.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "mediaconvert.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "mediaconvert.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "mediaconvert.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "subscribe.mediaconvert.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "mediaconvert.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "mediaconvert.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "mediaconvert.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "mediaconvert.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "mediaconvert.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "mediaconvert-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "mediaconvert-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "mediaconvert-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "mediaconvert-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "mediaconvert-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "mediaconvert.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "mediaconvert.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "mediaconvert.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "mediaconvert.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "mediaconvert.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "mediaconvert.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "mediaconvert", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "mediaconvert.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "mediaconvert.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "mediaconvert.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "mediaconvert.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "mediaconvert.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mediaconvert", + regionHash, + partitionHash, + }); diff --git a/clients/client-medialive/endpoints.ts b/clients/client-medialive/endpoints.ts index 2c50fc9b3485c..5579f2d8bc3ae 100644 --- a/clients/client-medialive/endpoints.ts +++ b/clients/client-medialive/endpoints.ts @@ -1,195 +1,73 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "medialive.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "medialive.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "medialive.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "medialive.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "medialive.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "medialive-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "medialive-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-2": { + hostname: "medialive-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "medialive.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "medialive.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "medialive.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "medialive.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "medialive.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "medialive.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "medialive.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "medialive.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "medialive.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "medialive.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "medialive-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "medialive-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "medialive-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "medialive.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "medialive.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "medialive.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "medialive.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "medialive.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "medialive", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "medialive.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "medialive.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "medialive.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "medialive.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "medialive.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "medialive", + regionHash, + partitionHash, + }); diff --git a/clients/client-mediapackage-vod/endpoints.ts b/clients/client-mediapackage-vod/endpoints.ts index 2f0327d2f4a89..a4501638ee60b 100644 --- a/clients/client-mediapackage-vod/endpoints.ts +++ b/clients/client-mediapackage-vod/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "mediapackage-vod.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "mediapackage-vod.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "mediapackage-vod.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "mediapackage-vod.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "mediapackage-vod.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "mediapackage-vod", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "mediapackage-vod.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "mediapackage-vod.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "mediapackage-vod.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "mediapackage-vod.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "mediapackage-vod.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mediapackage-vod", + regionHash, + partitionHash, + }); diff --git a/clients/client-mediapackage/endpoints.ts b/clients/client-mediapackage/endpoints.ts index ccc955b40d783..82bc44db42fc6 100644 --- a/clients/client-mediapackage/endpoints.ts +++ b/clients/client-mediapackage/endpoints.ts @@ -1,180 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "mediapackage.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "mediapackage.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "mediapackage.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "mediapackage.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "mediapackage.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "mediapackage.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "mediapackage.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "mediapackage.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "mediapackage.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "mediapackage.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "mediapackage.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "mediapackage.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "mediapackage.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "mediapackage.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "mediapackage.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "mediapackage.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "mediapackage.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "mediapackage.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "mediapackage.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "mediapackage.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "mediapackage.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "mediapackage", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "mediapackage.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "mediapackage.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "mediapackage.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "mediapackage.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "mediapackage.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mediapackage", + regionHash, + partitionHash, + }); diff --git a/clients/client-mediastore-data/endpoints.ts b/clients/client-mediastore-data/endpoints.ts index f5c98136bbb94..62a9d28fd8e3b 100644 --- a/clients/client-mediastore-data/endpoints.ts +++ b/clients/client-mediastore-data/endpoints.ts @@ -1,138 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "data.mediastore.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "data.mediastore.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "data.mediastore.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "data.mediastore.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "data.mediastore.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "data.mediastore.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "data.mediastore.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "data.mediastore.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "data.mediastore.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "data.mediastore.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "data.mediastore.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "data.mediastore.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "data.mediastore.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "data.mediastore.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "mediastore", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "data.mediastore.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "data.mediastore.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "data.mediastore.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "data.mediastore.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "data.mediastore.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mediastore", + regionHash, + partitionHash, + }); diff --git a/clients/client-mediastore/endpoints.ts b/clients/client-mediastore/endpoints.ts index acffe20f27c70..412160f402489 100644 --- a/clients/client-mediastore/endpoints.ts +++ b/clients/client-mediastore/endpoints.ts @@ -1,138 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "mediastore.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "mediastore.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "mediastore.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "mediastore.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "mediastore.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "mediastore.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "mediastore.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "mediastore.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "mediastore.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "mediastore.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "mediastore.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "mediastore.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "mediastore.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "mediastore.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "mediastore", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "mediastore.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "mediastore.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "mediastore.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "mediastore.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "mediastore.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mediastore", + regionHash, + partitionHash, + }); diff --git a/clients/client-mediatailor/endpoints.ts b/clients/client-mediatailor/endpoints.ts index 50692a526d8d0..016c89f9991c0 100644 --- a/clients/client-mediatailor/endpoints.ts +++ b/clients/client-mediatailor/endpoints.ts @@ -1,126 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "api.mediatailor.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "api.mediatailor.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "api.mediatailor.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "api.mediatailor.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "api.mediatailor.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "api.mediatailor.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "api.mediatailor.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "api.mediatailor.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "api.mediatailor.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "api.mediatailor.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "api.mediatailor.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "api.mediatailor.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "mediatailor", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "api.mediatailor.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "api.mediatailor.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "api.mediatailor.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "api.mediatailor.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "api.mediatailor.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mediatailor", + regionHash, + partitionHash, + }); diff --git a/clients/client-memorydb/endpoints.ts b/clients/client-memorydb/endpoints.ts index d99d63489ead0..70b0dfd63b693 100644 --- a/clients/client-memorydb/endpoints.ts +++ b/clients/client-memorydb/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "memory-db.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "memory-db.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "memory-db.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "memory-db.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "memory-db.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "memorydb", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "memory-db.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "memory-db.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "memory-db.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "memory-db.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "memory-db.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "memorydb", + regionHash, + partitionHash, + }); diff --git a/clients/client-mgn/endpoints.ts b/clients/client-mgn/endpoints.ts index 18eaabc94cb40..6da1164021818 100644 --- a/clients/client-mgn/endpoints.ts +++ b/clients/client-mgn/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "mgn.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "mgn.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "mgn.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "mgn.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "mgn.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "mgn", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "mgn.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "mgn.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "mgn.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "mgn.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "mgn.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mgn", + regionHash, + partitionHash, + }); diff --git a/clients/client-migration-hub/endpoints.ts b/clients/client-migration-hub/endpoints.ts index 7d1659bbfa457..4a1922aa69f91 100644 --- a/clients/client-migration-hub/endpoints.ts +++ b/clients/client-migration-hub/endpoints.ts @@ -1,126 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "mgh.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "mgh.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "mgh.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "mgh.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "mgh.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "mgh.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "mgh.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "mgh.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "mgh.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "mgh.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "mgh.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "mgh.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "mgh", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "mgh.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "mgh.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "mgh.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "mgh.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "mgh.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mgh", + regionHash, + partitionHash, + }); diff --git a/clients/client-migrationhub-config/endpoints.ts b/clients/client-migrationhub-config/endpoints.ts index c40941c7c06de..c222cb7ee3a57 100644 --- a/clients/client-migrationhub-config/endpoints.ts +++ b/clients/client-migrationhub-config/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "migrationhub-config.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "migrationhub-config.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "migrationhub-config.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "migrationhub-config.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "migrationhub-config.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "mgh", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "migrationhub-config.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "migrationhub-config.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "migrationhub-config.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "migrationhub-config.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "migrationhub-config.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mgh", + regionHash, + partitionHash, + }); diff --git a/clients/client-mobile/endpoints.ts b/clients/client-mobile/endpoints.ts index be5f1aa31a4e9..315ad84db5428 100644 --- a/clients/client-mobile/endpoints.ts +++ b/clients/client-mobile/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "mobile.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "mobile.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "mobile.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "mobile.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "mobile.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "awsmobilehubservice", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "mobile.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "mobile.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "mobile.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "mobile.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "mobile.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "awsmobilehubservice", + regionHash, + partitionHash, + }); diff --git a/clients/client-mq/endpoints.ts b/clients/client-mq/endpoints.ts index 3062d552816c0..33ffc390d210d 100644 --- a/clients/client-mq/endpoints.ts +++ b/clients/client-mq/endpoints.ts @@ -1,270 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "mq.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "mq.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "mq.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "mq.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "mq.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "mq-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "mq-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "mq-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "mq-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "mq-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "mq-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "mq.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "mq.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "mq.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "mq.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "mq.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "mq.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "mq.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "mq.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "mq.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "mq.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "mq.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "mq.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "mq.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "mq.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "mq.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "mq.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "mq-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "mq-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "mq-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "mq-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "mq-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "mq-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "mq.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "mq.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "mq.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "mq.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "mq.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "mq.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "mq.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "mq.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "mq", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "mq.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "mq.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "mq.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "mq.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "mq.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mq", + regionHash, + partitionHash, + }); diff --git a/clients/client-mturk/endpoints.ts b/clients/client-mturk/endpoints.ts index 0b0670f022631..de52d8a208dd8 100644 --- a/clients/client-mturk/endpoints.ts +++ b/clients/client-mturk/endpoints.ts @@ -1,96 +1,62 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "mturk-requester.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "mturk-requester.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "mturk-requester.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "mturk-requester.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "mturk-requester.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + sandbox: { + hostname: "mturk-requester-sandbox.us-east-1.amazonaws.com", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "sandbox": - regionInfo = { - hostname: "mturk-requester-sandbox.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "mturk-requester.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "mturk-requester", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "sandbox", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "mturk-requester.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "mturk-requester.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "mturk-requester.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "mturk-requester.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "mturk-requester.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mturk-requester", + regionHash, + partitionHash, + }); diff --git a/clients/client-mwaa/endpoints.ts b/clients/client-mwaa/endpoints.ts index ce64eb912b66e..086824b47adaa 100644 --- a/clients/client-mwaa/endpoints.ts +++ b/clients/client-mwaa/endpoints.ts @@ -1,138 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "airflow.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "airflow.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "airflow.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "airflow.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "airflow.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "airflow.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "airflow.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "airflow.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "airflow.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "airflow.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "airflow.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "airflow.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "airflow.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "airflow.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "airflow", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "airflow.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "airflow.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "airflow.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "airflow.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "airflow.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "airflow", + regionHash, + partitionHash, + }); diff --git a/clients/client-neptune/endpoints.ts b/clients/client-neptune/endpoints.ts index 0b266f527507b..c6b4b1921027e 100644 --- a/clients/client-neptune/endpoints.ts +++ b/clients/client-neptune/endpoints.ts @@ -1,295 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "rds.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "rds.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "rds.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "rds.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "rds.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "rds-fips.ca-central-1": { + hostname: "rds-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "rds-fips.us-east-1": { + hostname: "rds-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "rds-fips.us-east-2": { + hostname: "rds-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "rds-fips.us-west-1": { + hostname: "rds-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "rds-fips.us-west-2": { + hostname: "rds-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "rds.us-gov-east-1": { + hostname: "rds.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "rds.us-gov-west-1": { + hostname: "rds.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "rds.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "rds.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "rds.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "rds.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "rds.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "rds.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "rds.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "rds.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "rds.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "rds.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "rds.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "rds.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "rds.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "rds.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "rds.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "rds.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "rds.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "rds.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "rds-fips.ca-central-1": - regionInfo = { - hostname: "rds-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "rds-fips.us-east-1": - regionInfo = { - hostname: "rds-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "rds-fips.us-east-2": - regionInfo = { - hostname: "rds-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "rds-fips.us-west-1": - regionInfo = { - hostname: "rds-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "rds-fips.us-west-2": - regionInfo = { - hostname: "rds-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "rds.us-gov-east-1": - regionInfo = { - hostname: "rds.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "rds.us-gov-west-1": - regionInfo = { - hostname: "rds.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "rds.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "rds.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "rds.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "rds.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "rds.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "rds.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "rds.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "rds.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "rds.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "rds", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "rds-fips.ca-central-1", + "rds-fips.us-east-1", + "rds-fips.us-east-2", + "rds-fips.us-west-1", + "rds-fips.us-west-2", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "rds.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "rds.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "rds.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "rds.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["rds.us-gov-east-1", "rds.us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "rds.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "rds", + regionHash, + partitionHash, + }); diff --git a/clients/client-network-firewall/endpoints.ts b/clients/client-network-firewall/endpoints.ts index 3d49c41bbec56..d578cf6d75259 100644 --- a/clients/client-network-firewall/endpoints.ts +++ b/clients/client-network-firewall/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "network-firewall.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "network-firewall.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "network-firewall.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "network-firewall.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "network-firewall.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "network-firewall", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "network-firewall.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "network-firewall.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "network-firewall.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "network-firewall.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "network-firewall.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "network-firewall", + regionHash, + partitionHash, + }); diff --git a/clients/client-networkmanager/endpoints.ts b/clients/client-networkmanager/endpoints.ts index 90f5c74acbc5a..c5469ffbf0679 100644 --- a/clients/client-networkmanager/endpoints.ts +++ b/clients/client-networkmanager/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "networkmanager.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "networkmanager.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "networkmanager.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "networkmanager.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "networkmanager.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "networkmanager", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "networkmanager.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "networkmanager.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "networkmanager.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "networkmanager.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "networkmanager.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "networkmanager", + regionHash, + partitionHash, + }); diff --git a/clients/client-nimble/endpoints.ts b/clients/client-nimble/endpoints.ts index f561c67afc6f5..570727d3f040a 100644 --- a/clients/client-nimble/endpoints.ts +++ b/clients/client-nimble/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "nimble.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "nimble.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "nimble.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "nimble.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "nimble.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "nimble", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "nimble.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "nimble.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "nimble.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "nimble.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "nimble.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "nimble", + regionHash, + partitionHash, + }); diff --git a/clients/client-opsworks/endpoints.ts b/clients/client-opsworks/endpoints.ts index 038a03ea2c5b3..3d3441dc581c1 100644 --- a/clients/client-opsworks/endpoints.ts +++ b/clients/client-opsworks/endpoints.ts @@ -1,174 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "opsworks.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "opsworks.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "opsworks.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "opsworks.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "opsworks.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "opsworks.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "opsworks.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "opsworks.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "opsworks.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "opsworks.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "opsworks.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "opsworks.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "opsworks.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "opsworks.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "opsworks.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "opsworks.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "opsworks.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "opsworks.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "opsworks.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "opsworks.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "opsworks", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "opsworks.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "opsworks.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "opsworks.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "opsworks.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "opsworks.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "opsworks", + regionHash, + partitionHash, + }); diff --git a/clients/client-opsworkscm/endpoints.ts b/clients/client-opsworkscm/endpoints.ts index 1f1c6fec5fa3e..7eac07bcd1aa6 100644 --- a/clients/client-opsworkscm/endpoints.ts +++ b/clients/client-opsworkscm/endpoints.ts @@ -1,138 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "opsworks-cm.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "opsworks-cm.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "opsworks-cm.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "opsworks-cm.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "opsworks-cm.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "opsworks-cm.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "opsworks-cm.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "opsworks-cm.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "opsworks-cm.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "opsworks-cm.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "opsworks-cm.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "opsworks-cm.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "opsworks-cm.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "opsworks-cm.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "opsworks-cm", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "opsworks-cm.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "opsworks-cm.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "opsworks-cm.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "opsworks-cm.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "opsworks-cm.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "opsworks-cm", + regionHash, + partitionHash, + }); diff --git a/clients/client-organizations/endpoints.ts b/clients/client-organizations/endpoints.ts index b4ff0328c77c2..249fe1d55ffb8 100644 --- a/clients/client-organizations/endpoints.ts +++ b/clients/client-organizations/endpoints.ts @@ -1,107 +1,80 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "organizations.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "organizations.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "organizations.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "organizations.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "organizations.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-cn-global": { + hostname: "organizations.cn-northwest-1.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "aws-global": { + hostname: "organizations.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "aws-us-gov-global": { + hostname: "organizations.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-aws-global": { + hostname: "organizations-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-aws-us-gov-global": { + hostname: "organizations.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "aws-cn-global": - regionInfo = { - hostname: "organizations.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "aws-global": - regionInfo = { - hostname: "organizations.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "aws-us-gov-global": - regionInfo = { - hostname: "organizations.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-aws-global": - regionInfo = { - hostname: "organizations-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-aws-us-gov-global": - regionInfo = { - hostname: "organizations.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-global"); - } - if (AWS_CN_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-cn-global"); - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-us-gov-global"); - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - return defaultRegionInfoProvider("aws-global"); - } - } - return Promise.resolve({ signingService: "organizations", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-aws-global", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + endpoint: "aws-global", + }, + "aws-cn": { + regions: ["aws-cn-global", "cn-north-1", "cn-northwest-1"], + endpoint: "aws-cn-global", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "organizations.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "organizations.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["aws-us-gov-global", "fips-aws-us-gov-global", "us-gov-east-1", "us-gov-west-1"], + endpoint: "aws-us-gov-global", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "organizations", + regionHash, + partitionHash, + }); diff --git a/clients/client-outposts/endpoints.ts b/clients/client-outposts/endpoints.ts index f24e934e53f02..96d681fb598b4 100644 --- a/clients/client-outposts/endpoints.ts +++ b/clients/client-outposts/endpoints.ts @@ -1,265 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "outposts.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "outposts.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "outposts.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "outposts.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "outposts.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "outposts-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "outposts-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "outposts-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "outposts-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "outposts-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "outposts.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "outposts.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "outposts.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "outposts.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "outposts.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "outposts.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "outposts.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "outposts.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "outposts.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "outposts.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "outposts.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "outposts.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "outposts.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "outposts.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "outposts.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "outposts.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "outposts.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "outposts-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "outposts-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "outposts-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "outposts-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "outposts-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "outposts.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "outposts.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "outposts.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "outposts.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "outposts.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "outposts.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "outposts.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "outposts.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "outposts.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "outposts", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "outposts.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "outposts.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "outposts.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "outposts.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "outposts.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "outposts", + regionHash, + partitionHash, + }); diff --git a/clients/client-personalize-events/endpoints.ts b/clients/client-personalize-events/endpoints.ts index 54f078410103a..91ccd91479886 100644 --- a/clients/client-personalize-events/endpoints.ts +++ b/clients/client-personalize-events/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "personalize-events.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "personalize-events.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "personalize-events.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "personalize-events.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "personalize-events.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "personalize", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "personalize-events.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "personalize-events.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "personalize-events.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "personalize-events.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "personalize-events.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "personalize", + regionHash, + partitionHash, + }); diff --git a/clients/client-personalize-runtime/endpoints.ts b/clients/client-personalize-runtime/endpoints.ts index a7790ef6aa1a7..3aa629151b01d 100644 --- a/clients/client-personalize-runtime/endpoints.ts +++ b/clients/client-personalize-runtime/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "personalize-runtime.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "personalize-runtime.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "personalize-runtime.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "personalize-runtime.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "personalize-runtime.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "personalize", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "personalize-runtime.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "personalize-runtime.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "personalize-runtime.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "personalize-runtime.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "personalize-runtime.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "personalize", + regionHash, + partitionHash, + }); diff --git a/clients/client-personalize/endpoints.ts b/clients/client-personalize/endpoints.ts index 16f5093c88c4a..9cd172647eb90 100644 --- a/clients/client-personalize/endpoints.ts +++ b/clients/client-personalize/endpoints.ts @@ -1,156 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "personalize.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "personalize.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "personalize.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "personalize.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "personalize.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "personalize.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "personalize.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "personalize.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "personalize.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "personalize.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "personalize.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "personalize.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "personalize.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "personalize.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "personalize.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "personalize.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "personalize.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "personalize", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "personalize.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "personalize.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "personalize.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "personalize.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "personalize.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "personalize", + regionHash, + partitionHash, + }); diff --git a/clients/client-pi/endpoints.ts b/clients/client-pi/endpoints.ts index 6b1bd316cfe28..8a12b0e5c16f9 100644 --- a/clients/client-pi/endpoints.ts +++ b/clients/client-pi/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "pi.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "pi.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "pi.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "pi.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "pi.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "pi", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "pi.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "pi.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "pi.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "pi.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "pi.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "pi", + regionHash, + partitionHash, + }); diff --git a/clients/client-pinpoint-email/endpoints.ts b/clients/client-pinpoint-email/endpoints.ts index a050ecf2690b7..97e12a6d7fe3b 100644 --- a/clients/client-pinpoint-email/endpoints.ts +++ b/clients/client-pinpoint-email/endpoints.ts @@ -1,133 +1,62 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "email.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "email.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "email.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "email.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "email.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-gov-west-1": { + hostname: "email-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-south-1": - regionInfo = { - hostname: "email.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "email.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "email.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "email.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "email-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "email.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "email.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "email.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ses", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "email.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "email.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "email.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "email.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "email.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ses", + regionHash, + partitionHash, + }); diff --git a/clients/client-pinpoint-sms-voice/endpoints.ts b/clients/client-pinpoint-sms-voice/endpoints.ts index fe7fe51986a85..4ae8f508eeda5 100644 --- a/clients/client-pinpoint-sms-voice/endpoints.ts +++ b/clients/client-pinpoint-sms-voice/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "sms-voice.pinpoint.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "sms-voice.pinpoint.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "sms-voice.pinpoint.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "sms-voice.pinpoint.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "sms-voice.pinpoint.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "sms-voice", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "sms-voice.pinpoint.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "sms-voice.pinpoint.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "sms-voice.pinpoint.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "sms-voice.pinpoint.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "sms-voice.pinpoint.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "sms-voice", + regionHash, + partitionHash, + }); diff --git a/clients/client-pinpoint/endpoints.ts b/clients/client-pinpoint/endpoints.ts index 3f51d7e94f1f2..4d38be7a7e07f 100644 --- a/clients/client-pinpoint/endpoints.ts +++ b/clients/client-pinpoint/endpoints.ts @@ -1,192 +1,84 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "pinpoint.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "pinpoint.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "pinpoint.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "pinpoint.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "pinpoint.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "pinpoint-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-gov-west-1": { + hostname: "pinpoint-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-2": { + hostname: "pinpoint-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-east-1": { + hostname: "pinpoint.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-gov-west-1": { + hostname: "pinpoint.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-2": { + hostname: "pinpoint.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "pinpoint.ap-northeast-1.amazonaws.com", - partition: "aws", - signingService: "mobiletargeting", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "pinpoint.ap-northeast-2.amazonaws.com", - partition: "aws", - signingService: "mobiletargeting", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "pinpoint.ap-south-1.amazonaws.com", - partition: "aws", - signingService: "mobiletargeting", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "pinpoint.ap-southeast-1.amazonaws.com", - partition: "aws", - signingService: "mobiletargeting", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "pinpoint.ap-southeast-2.amazonaws.com", - partition: "aws", - signingService: "mobiletargeting", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "pinpoint.ca-central-1.amazonaws.com", - partition: "aws", - signingService: "mobiletargeting", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "pinpoint.eu-central-1.amazonaws.com", - partition: "aws", - signingService: "mobiletargeting", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "pinpoint.eu-west-1.amazonaws.com", - partition: "aws", - signingService: "mobiletargeting", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "pinpoint.eu-west-2.amazonaws.com", - partition: "aws", - signingService: "mobiletargeting", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "pinpoint-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "pinpoint-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "pinpoint-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "pinpoint.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "pinpoint.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "pinpoint.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "mobiletargeting", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - signingService: "mobiletargeting", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "mobiletargeting", - }; - } - } - return Promise.resolve({ signingService: "mobiletargeting", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "pinpoint.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "pinpoint.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "pinpoint.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "pinpoint.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "pinpoint.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "mobiletargeting", + regionHash, + partitionHash, + }); diff --git a/clients/client-polly/endpoints.ts b/clients/client-polly/endpoints.ts index e033b7a1913b5..cbb4f388f8515 100644 --- a/clients/client-polly/endpoints.ts +++ b/clients/client-polly/endpoints.ts @@ -1,239 +1,82 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "polly.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "polly.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "polly.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "polly.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "polly.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "polly-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "polly-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-west-1": { + hostname: "polly-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "polly-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "polly-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "polly.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "polly.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "polly.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "polly.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "polly.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "polly.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "polly.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "polly.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "polly.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "polly.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "polly.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "polly.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "polly.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "polly-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "polly-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "polly-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "polly-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "polly-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "polly.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "polly.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "polly.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "polly.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "polly.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "polly.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "polly.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "polly", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "polly.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "polly.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "polly.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "polly.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "polly.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "polly", + regionHash, + partitionHash, + }); diff --git a/clients/client-pricing/endpoints.ts b/clients/client-pricing/endpoints.ts index ca286e6974afe..cc57017912853 100644 --- a/clients/client-pricing/endpoints.ts +++ b/clients/client-pricing/endpoints.ts @@ -1,100 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "api.pricing.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "api.pricing.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "api.pricing.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "api.pricing.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "api.pricing.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-south-1": - regionInfo = { - hostname: "api.pricing.ap-south-1.amazonaws.com", - partition: "aws", - signingService: "pricing", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "api.pricing.us-east-1.amazonaws.com", - partition: "aws", - signingService: "pricing", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "pricing", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - signingService: "pricing", - }; - } - } - return Promise.resolve({ signingService: "pricing", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "api.pricing.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "api.pricing.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "api.pricing.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "api.pricing.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "api.pricing.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "pricing", + regionHash, + partitionHash, + }); diff --git a/clients/client-proton/endpoints.ts b/clients/client-proton/endpoints.ts index 1c264ae5f9b2d..cebc19573c2e2 100644 --- a/clients/client-proton/endpoints.ts +++ b/clients/client-proton/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "proton.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "proton.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "proton.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "proton.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "proton.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "proton", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "proton.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "proton.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "proton.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "proton.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "proton.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "proton", + regionHash, + partitionHash, + }); diff --git a/clients/client-qldb-session/endpoints.ts b/clients/client-qldb-session/endpoints.ts index 436be23dfe3d8..701f24f2ce030 100644 --- a/clients/client-qldb-session/endpoints.ts +++ b/clients/client-qldb-session/endpoints.ts @@ -1,165 +1,73 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "session.qldb.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "session.qldb.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "session.qldb.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "session.qldb.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "session.qldb.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "session.qldb-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "session.qldb-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-2": { + hostname: "session.qldb-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "session.qldb.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "session.qldb.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "session.qldb.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "session.qldb.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "session.qldb.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "session.qldb.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "session.qldb.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "session.qldb-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "session.qldb-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "session.qldb-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "session.qldb.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "session.qldb.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "session.qldb.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "qldb", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "session.qldb.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "session.qldb.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "session.qldb.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "session.qldb.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "session.qldb.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "qldb", + regionHash, + partitionHash, + }); diff --git a/clients/client-qldb/endpoints.ts b/clients/client-qldb/endpoints.ts index 0ff16c8ecb437..65e4b5ff14f75 100644 --- a/clients/client-qldb/endpoints.ts +++ b/clients/client-qldb/endpoints.ts @@ -1,165 +1,73 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "qldb.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "qldb.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "qldb.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "qldb.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "qldb.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "qldb-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "qldb-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-2": { + hostname: "qldb-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "qldb.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "qldb.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "qldb.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "qldb.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "qldb.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "qldb.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "qldb.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "qldb-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "qldb-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "qldb-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "qldb.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "qldb.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "qldb.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "qldb", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "qldb.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "qldb.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "qldb.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "qldb.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "qldb.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "qldb", + regionHash, + partitionHash, + }); diff --git a/clients/client-quicksight/endpoints.ts b/clients/client-quicksight/endpoints.ts index 9f994a1c1a4a2..df5a42b80ae01 100644 --- a/clients/client-quicksight/endpoints.ts +++ b/clients/client-quicksight/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "quicksight.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "quicksight.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "quicksight.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "quicksight.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "quicksight.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "quicksight", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "quicksight.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "quicksight.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "quicksight.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "quicksight.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "quicksight.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "quicksight", + regionHash, + partitionHash, + }); diff --git a/clients/client-ram/endpoints.ts b/clients/client-ram/endpoints.ts index fdb63a45758c6..bb361f57d5ee4 100644 --- a/clients/client-ram/endpoints.ts +++ b/clients/client-ram/endpoints.ts @@ -1,277 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "ram.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "ram.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "ram.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "ram.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "ram.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "ram-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "ram-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "ram-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "ram-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "ram-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "ram.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "ram.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "ram.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "ram.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "ram.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "ram.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "ram.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "ram.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "ram.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "ram.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "ram.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "ram.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "ram.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "ram.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "ram.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "ram.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "ram.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "ram.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "ram.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "ram-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "ram-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "ram-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "ram-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "ram-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "ram.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "ram.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "ram.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "ram.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "ram.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "ram.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "ram.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "ram.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "ram.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ram", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "ram.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "ram.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "ram.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "ram.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "ram.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ram", + regionHash, + partitionHash, + }); diff --git a/clients/client-rds-data/endpoints.ts b/clients/client-rds-data/endpoints.ts index a70f5d29fafa3..57874d47db321 100644 --- a/clients/client-rds-data/endpoints.ts +++ b/clients/client-rds-data/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "rds-data.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "rds-data.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "rds-data.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "rds-data.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "rds-data.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "rds-data", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "rds-data.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "rds-data.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "rds-data.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "rds-data.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "rds-data.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "rds-data", + regionHash, + partitionHash, + }); diff --git a/clients/client-rds/endpoints.ts b/clients/client-rds/endpoints.ts index 0b266f527507b..c6b4b1921027e 100644 --- a/clients/client-rds/endpoints.ts +++ b/clients/client-rds/endpoints.ts @@ -1,295 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "rds.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "rds.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "rds.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "rds.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "rds.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "rds-fips.ca-central-1": { + hostname: "rds-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "rds-fips.us-east-1": { + hostname: "rds-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "rds-fips.us-east-2": { + hostname: "rds-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "rds-fips.us-west-1": { + hostname: "rds-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "rds-fips.us-west-2": { + hostname: "rds-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "rds.us-gov-east-1": { + hostname: "rds.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "rds.us-gov-west-1": { + hostname: "rds.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "rds.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "rds.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "rds.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "rds.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "rds.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "rds.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "rds.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "rds.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "rds.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "rds.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "rds.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "rds.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "rds.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "rds.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "rds.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "rds.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "rds.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "rds.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "rds-fips.ca-central-1": - regionInfo = { - hostname: "rds-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "rds-fips.us-east-1": - regionInfo = { - hostname: "rds-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "rds-fips.us-east-2": - regionInfo = { - hostname: "rds-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "rds-fips.us-west-1": - regionInfo = { - hostname: "rds-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "rds-fips.us-west-2": - regionInfo = { - hostname: "rds-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "rds.us-gov-east-1": - regionInfo = { - hostname: "rds.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "rds.us-gov-west-1": - regionInfo = { - hostname: "rds.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "rds.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "rds.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "rds.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "rds.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "rds.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "rds.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "rds.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "rds.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "rds.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "rds", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "rds-fips.ca-central-1", + "rds-fips.us-east-1", + "rds-fips.us-east-2", + "rds-fips.us-west-1", + "rds-fips.us-west-2", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "rds.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "rds.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "rds.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "rds.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["rds.us-gov-east-1", "rds.us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "rds.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "rds", + regionHash, + partitionHash, + }); diff --git a/clients/client-redshift-data/endpoints.ts b/clients/client-redshift-data/endpoints.ts index 586a2ae02d309..ba234bf577085 100644 --- a/clients/client-redshift-data/endpoints.ts +++ b/clients/client-redshift-data/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "redshift-data.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "redshift-data.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "redshift-data.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "redshift-data.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "redshift-data.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "redshift-data", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "redshift-data.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "redshift-data.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "redshift-data.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "redshift-data.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "redshift-data.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "redshift-data", + regionHash, + partitionHash, + }); diff --git a/clients/client-redshift/endpoints.ts b/clients/client-redshift/endpoints.ts index 38affffeb083f..62fff57c2b011 100644 --- a/clients/client-redshift/endpoints.ts +++ b/clients/client-redshift/endpoints.ts @@ -1,283 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "redshift.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "redshift.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "redshift.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "redshift.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "redshift.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "redshift-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "redshift-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "redshift-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "redshift-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "redshift-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "redshift.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "redshift.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "redshift.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "redshift.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "redshift.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "redshift.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "redshift.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "redshift.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "redshift.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "redshift.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "redshift.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "redshift.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "redshift.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "redshift.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "redshift.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "redshift.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "redshift.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "redshift.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "redshift.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "redshift-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "redshift-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "redshift-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "redshift-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "redshift-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "redshift.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "redshift.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "redshift.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "redshift.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "redshift.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "redshift.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "redshift.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "redshift.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "redshift.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "redshift.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "redshift", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "redshift.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "redshift.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "redshift.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "redshift.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "redshift.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "redshift", + regionHash, + partitionHash, + }); diff --git a/clients/client-rekognition/endpoints.ts b/clients/client-rekognition/endpoints.ts index 74e07d0270344..3a53a61cc73d0 100644 --- a/clients/client-rekognition/endpoints.ts +++ b/clients/client-rekognition/endpoints.ts @@ -1,210 +1,87 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "rekognition.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "rekognition.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "rekognition.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "rekognition.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "rekognition.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "rekognition-fips.ca-central-1": { + hostname: "rekognition-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "rekognition-fips.us-east-1": { + hostname: "rekognition-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "rekognition-fips.us-east-2": { + hostname: "rekognition-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "rekognition-fips.us-gov-west-1": { + hostname: "rekognition-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "rekognition-fips.us-west-1": { + hostname: "rekognition-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "rekognition-fips.us-west-2": { + hostname: "rekognition-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "rekognition.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "rekognition.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "rekognition.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "rekognition.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "rekognition.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "rekognition.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "rekognition.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "rekognition.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "rekognition.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "rekognition-fips.ca-central-1": - regionInfo = { - hostname: "rekognition-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "rekognition-fips.us-east-1": - regionInfo = { - hostname: "rekognition-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "rekognition-fips.us-east-2": - regionInfo = { - hostname: "rekognition-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "rekognition-fips.us-gov-west-1": - regionInfo = { - hostname: "rekognition-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "rekognition-fips.us-west-1": - regionInfo = { - hostname: "rekognition-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "rekognition-fips.us-west-2": - regionInfo = { - hostname: "rekognition-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "rekognition.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "rekognition.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "rekognition.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "rekognition.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "rekognition.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "rekognition", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "rekognition-fips.ca-central-1", + "rekognition-fips.us-east-1", + "rekognition-fips.us-east-2", + "rekognition-fips.us-west-1", + "rekognition-fips.us-west-2", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "rekognition.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "rekognition.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "rekognition.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "rekognition.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["rekognition-fips.us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "rekognition.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "rekognition", + regionHash, + partitionHash, + }); diff --git a/clients/client-resource-groups-tagging-api/endpoints.ts b/clients/client-resource-groups-tagging-api/endpoints.ts index 8d9c61f688247..980ce89a6ddac 100644 --- a/clients/client-resource-groups-tagging-api/endpoints.ts +++ b/clients/client-resource-groups-tagging-api/endpoints.ts @@ -1,240 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "tagging.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "tagging.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "tagging.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "tagging.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "tagging.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "tagging.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "tagging.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "tagging.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "tagging.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "tagging.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "tagging.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "tagging.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "tagging.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "tagging.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "tagging.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "tagging.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "tagging.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "tagging.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "tagging.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "tagging.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "tagging.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "tagging.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "tagging.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "tagging.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "tagging.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "tagging.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "tagging.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "tagging.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "tagging.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "tagging.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "tagging.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "tagging", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "tagging.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "tagging.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "tagging.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "tagging.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "tagging.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "tagging", + regionHash, + partitionHash, + }); diff --git a/clients/client-resource-groups/endpoints.ts b/clients/client-resource-groups/endpoints.ts index 9a10bd4e314d2..1d661cb17366f 100644 --- a/clients/client-resource-groups/endpoints.ts +++ b/clients/client-resource-groups/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "resource-groups.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "resource-groups.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "resource-groups.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "resource-groups.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "resource-groups.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "resource-groups-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "resource-groups-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "resource-groups.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "resource-groups.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "resource-groups-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "resource-groups-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "resource-groups.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "resource-groups.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "resource-groups.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "resource-groups.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "resource-groups.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "resource-groups.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "resource-groups.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "resource-groups.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "resource-groups.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "resource-groups.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "resource-groups.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "resource-groups.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "resource-groups.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "resource-groups.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "resource-groups.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "resource-groups.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "resource-groups.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "resource-groups-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "resource-groups-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "resource-groups.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "resource-groups.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "resource-groups-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "resource-groups-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "resource-groups.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "resource-groups.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "resource-groups.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "resource-groups.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "resource-groups.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "resource-groups.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "resource-groups.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "resource-groups.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "resource-groups", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "resource-groups.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "resource-groups.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "resource-groups.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "resource-groups.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "resource-groups.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "resource-groups", + regionHash, + partitionHash, + }); diff --git a/clients/client-robomaker/endpoints.ts b/clients/client-robomaker/endpoints.ts index 5ccf5338b428c..e61d8190015d8 100644 --- a/clients/client-robomaker/endpoints.ts +++ b/clients/client-robomaker/endpoints.ts @@ -1,126 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "robomaker.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "robomaker.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "robomaker.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "robomaker.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "robomaker.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "robomaker.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "robomaker.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "robomaker.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "robomaker.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "robomaker.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "robomaker.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "robomaker.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "robomaker", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "robomaker.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "robomaker.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "robomaker.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "robomaker.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "robomaker.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "robomaker", + regionHash, + partitionHash, + }); diff --git a/clients/client-route-53-domains/endpoints.ts b/clients/client-route-53-domains/endpoints.ts index d75608f8aae7c..712cb8b4e089b 100644 --- a/clients/client-route-53-domains/endpoints.ts +++ b/clients/client-route-53-domains/endpoints.ts @@ -1,90 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "route53domains.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "route53domains.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "route53domains.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "route53domains.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "route53domains.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "us-east-1": - regionInfo = { - hostname: "route53domains.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "route53domains", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "route53domains.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "route53domains.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "route53domains.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "route53domains.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "route53domains.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "route53domains", + regionHash, + partitionHash, + }); diff --git a/clients/client-route-53/endpoints.ts b/clients/client-route-53/endpoints.ts index a43244a2510b5..72bf643b48381 100644 --- a/clients/client-route-53/endpoints.ts +++ b/clients/client-route-53/endpoints.ts @@ -1,115 +1,88 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "route53.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "route53.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "route53.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "route53.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "route53.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-cn-global": { + hostname: "route53.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "aws-global": { + hostname: "route53.amazonaws.com", + signingRegion: "us-east-1", + }, + "aws-iso-b-global": { + hostname: "route53.sc2s.sgov.gov", + signingRegion: "us-isob-east-1", + }, + "aws-iso-global": { + hostname: "route53.c2s.ic.gov", + signingRegion: "us-iso-east-1", + }, + "aws-us-gov-global": { + hostname: "route53.us-gov.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-aws-global": { + hostname: "route53-fips.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-aws-us-gov-global": { + hostname: "route53.us-gov.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "aws-cn-global": - regionInfo = { - hostname: "route53.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "aws-global": - regionInfo = { - hostname: "route53.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "aws-iso-b-global": - regionInfo = { - hostname: "route53.sc2s.sgov.gov", - partition: "aws-iso-b", - signingRegion: "us-isob-east-1", - }; - break; - case "aws-iso-global": - regionInfo = { - hostname: "route53.c2s.ic.gov", - partition: "aws-iso", - signingRegion: "us-iso-east-1", - }; - break; - case "aws-us-gov-global": - regionInfo = { - hostname: "route53.us-gov.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-aws-global": - regionInfo = { - hostname: "route53-fips.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-aws-us-gov-global": - regionInfo = { - hostname: "route53.us-gov.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-global"); - } - if (AWS_CN_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-cn-global"); - } - if (AWS_ISO_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-iso-global"); - } - if (AWS_ISO_B_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-iso-b-global"); - } - if (AWS_US_GOV_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-us-gov-global"); - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - return defaultRegionInfoProvider("aws-global"); - } - } - return Promise.resolve({ signingService: "route53", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-aws-global", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + endpoint: "aws-global", + }, + "aws-cn": { + regions: ["aws-cn-global", "cn-north-1", "cn-northwest-1"], + endpoint: "aws-cn-global", + }, + "aws-iso": { + regions: ["aws-iso-global", "us-iso-east-1"], + endpoint: "aws-iso-global", + }, + "aws-iso-b": { + regions: ["aws-iso-b-global", "us-isob-east-1"], + endpoint: "aws-iso-b-global", + }, + "aws-us-gov": { + regions: ["aws-us-gov-global", "fips-aws-us-gov-global", "us-gov-east-1", "us-gov-west-1"], + endpoint: "aws-us-gov-global", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "route53", + regionHash, + partitionHash, + }); diff --git a/clients/client-route53-recovery-cluster/endpoints.ts b/clients/client-route53-recovery-cluster/endpoints.ts index 52e2d08ade966..bce15e5e579e9 100644 --- a/clients/client-route53-recovery-cluster/endpoints.ts +++ b/clients/client-route53-recovery-cluster/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "route53-recovery-cluster.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "route53-recovery-cluster.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "route53-recovery-cluster.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "route53-recovery-cluster.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "route53-recovery-cluster.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "route53-recovery-cluster", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "route53-recovery-cluster.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "route53-recovery-cluster.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "route53-recovery-cluster.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "route53-recovery-cluster.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "route53-recovery-cluster.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "route53-recovery-cluster", + regionHash, + partitionHash, + }); diff --git a/clients/client-route53-recovery-control-config/endpoints.ts b/clients/client-route53-recovery-control-config/endpoints.ts index be7381bee0357..f8768edbe00b7 100644 --- a/clients/client-route53-recovery-control-config/endpoints.ts +++ b/clients/client-route53-recovery-control-config/endpoints.ts @@ -1,91 +1,63 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "route53-recovery-control-config.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "route53-recovery-control-config.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "route53-recovery-control-config.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "route53-recovery-control-config.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "route53-recovery-control-config.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-global": { + hostname: "route53-recovery-control-config.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "aws-global": - regionInfo = { - hostname: "route53-recovery-control-config.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "route53-recovery-control-config", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "route53-recovery-control-config.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "route53-recovery-control-config.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "route53-recovery-control-config.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "route53-recovery-control-config.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "route53-recovery-control-config.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "route53-recovery-control-config", + regionHash, + partitionHash, + }); diff --git a/clients/client-route53-recovery-readiness/endpoints.ts b/clients/client-route53-recovery-readiness/endpoints.ts index f2be43e9fc0c5..a31dfaa6fb41b 100644 --- a/clients/client-route53-recovery-readiness/endpoints.ts +++ b/clients/client-route53-recovery-readiness/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "route53-recovery-readiness.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "route53-recovery-readiness.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "route53-recovery-readiness.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "route53-recovery-readiness.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "route53-recovery-readiness.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "route53-recovery-readiness", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "route53-recovery-readiness.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "route53-recovery-readiness.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "route53-recovery-readiness.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "route53-recovery-readiness.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "route53-recovery-readiness.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "route53-recovery-readiness", + regionHash, + partitionHash, + }); diff --git a/clients/client-route53resolver/endpoints.ts b/clients/client-route53resolver/endpoints.ts index 790284c905b21..45bd9322b4fd8 100644 --- a/clients/client-route53resolver/endpoints.ts +++ b/clients/client-route53resolver/endpoints.ts @@ -1,234 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "route53resolver.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "route53resolver.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "route53resolver.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "route53resolver.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "route53resolver.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "route53resolver.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "route53resolver.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "route53resolver.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "route53resolver.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "route53resolver.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "route53resolver.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "route53resolver.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "route53resolver.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "route53resolver.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "route53resolver.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "route53resolver.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "route53resolver.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "route53resolver.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "route53resolver.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "route53resolver.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "route53resolver.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "route53resolver.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "route53resolver.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "route53resolver.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "route53resolver.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "route53resolver.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "route53resolver.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "route53resolver.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "route53resolver.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "route53resolver.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "route53resolver", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "route53resolver.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "route53resolver.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "route53resolver.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "route53resolver.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "route53resolver.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "route53resolver", + regionHash, + partitionHash, + }); diff --git a/clients/client-s3-control/endpoints.ts b/clients/client-s3-control/endpoints.ts index a0bd56dd51ffb..ce753b3adffb1 100644 --- a/clients/client-s3-control/endpoints.ts +++ b/clients/client-s3-control/endpoints.ts @@ -1,280 +1,175 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "s3-control.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "s3-control.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "s3-control.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "s3-control.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "s3-control.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "ap-northeast-1": { + hostname: "s3-control.ap-northeast-1.amazonaws.com", + signingRegion: "ap-northeast-1", + }, + "ap-northeast-2": { + hostname: "s3-control.ap-northeast-2.amazonaws.com", + signingRegion: "ap-northeast-2", + }, + "ap-northeast-3": { + hostname: "s3-control.ap-northeast-3.amazonaws.com", + signingRegion: "ap-northeast-3", + }, + "ap-south-1": { + hostname: "s3-control.ap-south-1.amazonaws.com", + signingRegion: "ap-south-1", + }, + "ap-southeast-1": { + hostname: "s3-control.ap-southeast-1.amazonaws.com", + signingRegion: "ap-southeast-1", + }, + "ap-southeast-2": { + hostname: "s3-control.ap-southeast-2.amazonaws.com", + signingRegion: "ap-southeast-2", + }, + "ca-central-1": { + hostname: "s3-control.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "ca-central-1-fips": { + hostname: "s3-control-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "cn-north-1": { + hostname: "s3-control.cn-north-1.amazonaws.com.cn", + signingRegion: "cn-north-1", + }, + "cn-northwest-1": { + hostname: "s3-control.cn-northwest-1.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "eu-central-1": { + hostname: "s3-control.eu-central-1.amazonaws.com", + signingRegion: "eu-central-1", + }, + "eu-north-1": { + hostname: "s3-control.eu-north-1.amazonaws.com", + signingRegion: "eu-north-1", + }, + "eu-west-1": { + hostname: "s3-control.eu-west-1.amazonaws.com", + signingRegion: "eu-west-1", + }, + "eu-west-2": { + hostname: "s3-control.eu-west-2.amazonaws.com", + signingRegion: "eu-west-2", + }, + "eu-west-3": { + hostname: "s3-control.eu-west-3.amazonaws.com", + signingRegion: "eu-west-3", + }, + "sa-east-1": { + hostname: "s3-control.sa-east-1.amazonaws.com", + signingRegion: "sa-east-1", + }, + "us-east-1": { + hostname: "s3-control.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-1-fips": { + hostname: "s3-control-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2": { + hostname: "s3-control.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-east-2-fips": { + hostname: "s3-control-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1": { + hostname: "s3-control.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-east-1-fips": { + hostname: "s3-control-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "s3-control.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-gov-west-1-fips": { + hostname: "s3-control-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1": { + hostname: "s3-control.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-1-fips": { + hostname: "s3-control-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2": { + hostname: "s3-control.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-west-2-fips": { + hostname: "s3-control-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "s3-control.ap-northeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-1", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "s3-control.ap-northeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-2", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "s3-control.ap-northeast-3.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-3", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "s3-control.ap-south-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-south-1", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "s3-control.ap-southeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-1", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "s3-control.ap-southeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-2", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "s3-control.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "ca-central-1-fips": - regionInfo = { - hostname: "s3-control-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "s3-control.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-north-1", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "s3-control.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "s3-control.eu-central-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-central-1", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "s3-control.eu-north-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-north-1", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "s3-control.eu-west-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-1", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "s3-control.eu-west-2.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-2", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "s3-control.eu-west-3.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-3", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "s3-control.sa-east-1.amazonaws.com", - partition: "aws", - signingRegion: "sa-east-1", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "s3-control.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "s3-control-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "s3-control.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "s3-control-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "s3-control.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-east-1-fips": - regionInfo = { - hostname: "s3-control-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "s3-control.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "s3-control-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "s3-control.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "s3-control-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "s3-control.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "s3-control-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "s3", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "ca-central-1-fips", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "s3-control.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "s3-control.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "s3-control.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "s3-control.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-east-1-fips", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "s3-control.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "s3", + regionHash, + partitionHash, + }); diff --git a/clients/client-s3/endpoints.ts b/clients/client-s3/endpoints.ts index f45579a3a465d..b4da75b3e0516 100644 --- a/clients/client-s3/endpoints.ts +++ b/clients/client-s3/endpoints.ts @@ -1,459 +1,232 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "s3.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "s3.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "s3.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "s3.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "s3.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "accesspoint-af-south-1": { + hostname: "s3-accesspoint.af-south-1.amazonaws.com", + }, + "accesspoint-ap-east-1": { + hostname: "s3-accesspoint.ap-east-1.amazonaws.com", + }, + "accesspoint-ap-northeast-1": { + hostname: "s3-accesspoint.ap-northeast-1.amazonaws.com", + }, + "accesspoint-ap-northeast-2": { + hostname: "s3-accesspoint.ap-northeast-2.amazonaws.com", + }, + "accesspoint-ap-northeast-3": { + hostname: "s3-accesspoint.ap-northeast-3.amazonaws.com", + }, + "accesspoint-ap-south-1": { + hostname: "s3-accesspoint.ap-south-1.amazonaws.com", + }, + "accesspoint-ap-southeast-1": { + hostname: "s3-accesspoint.ap-southeast-1.amazonaws.com", + }, + "accesspoint-ap-southeast-2": { + hostname: "s3-accesspoint.ap-southeast-2.amazonaws.com", + }, + "accesspoint-ca-central-1": { + hostname: "s3-accesspoint.ca-central-1.amazonaws.com", + }, + "accesspoint-cn-north-1": { + hostname: "s3-accesspoint.cn-north-1.amazonaws.com.cn", + }, + "accesspoint-cn-northwest-1": { + hostname: "s3-accesspoint.cn-northwest-1.amazonaws.com.cn", + }, + "accesspoint-eu-central-1": { + hostname: "s3-accesspoint.eu-central-1.amazonaws.com", + }, + "accesspoint-eu-north-1": { + hostname: "s3-accesspoint.eu-north-1.amazonaws.com", + }, + "accesspoint-eu-south-1": { + hostname: "s3-accesspoint.eu-south-1.amazonaws.com", + }, + "accesspoint-eu-west-1": { + hostname: "s3-accesspoint.eu-west-1.amazonaws.com", + }, + "accesspoint-eu-west-2": { + hostname: "s3-accesspoint.eu-west-2.amazonaws.com", + }, + "accesspoint-eu-west-3": { + hostname: "s3-accesspoint.eu-west-3.amazonaws.com", + }, + "accesspoint-me-south-1": { + hostname: "s3-accesspoint.me-south-1.amazonaws.com", + }, + "accesspoint-sa-east-1": { + hostname: "s3-accesspoint.sa-east-1.amazonaws.com", + }, + "accesspoint-us-east-1": { + hostname: "s3-accesspoint.us-east-1.amazonaws.com", + }, + "accesspoint-us-east-2": { + hostname: "s3-accesspoint.us-east-2.amazonaws.com", + }, + "accesspoint-us-gov-east-1": { + hostname: "s3-accesspoint.us-gov-east-1.amazonaws.com", + }, + "accesspoint-us-gov-west-1": { + hostname: "s3-accesspoint.us-gov-west-1.amazonaws.com", + }, + "accesspoint-us-west-1": { + hostname: "s3-accesspoint.us-west-1.amazonaws.com", + }, + "accesspoint-us-west-2": { + hostname: "s3-accesspoint.us-west-2.amazonaws.com", + }, + "ap-northeast-1": { + hostname: "s3.ap-northeast-1.amazonaws.com", + }, + "ap-southeast-1": { + hostname: "s3.ap-southeast-1.amazonaws.com", + }, + "ap-southeast-2": { + hostname: "s3.ap-southeast-2.amazonaws.com", + }, + "aws-global": { + hostname: "s3.amazonaws.com", + signingRegion: "us-east-1", + }, + "eu-west-1": { + hostname: "s3.eu-west-1.amazonaws.com", + }, + "fips-accesspoint-ca-central-1": { + hostname: "s3-accesspoint-fips.ca-central-1.amazonaws.com", + }, + "fips-accesspoint-us-east-1": { + hostname: "s3-accesspoint-fips.us-east-1.amazonaws.com", + }, + "fips-accesspoint-us-east-2": { + hostname: "s3-accesspoint-fips.us-east-2.amazonaws.com", + }, + "fips-accesspoint-us-gov-east-1": { + hostname: "s3-accesspoint-fips.us-gov-east-1.amazonaws.com", + }, + "fips-accesspoint-us-gov-west-1": { + hostname: "s3-accesspoint-fips.us-gov-west-1.amazonaws.com", + }, + "fips-accesspoint-us-west-1": { + hostname: "s3-accesspoint-fips.us-west-1.amazonaws.com", + }, + "fips-accesspoint-us-west-2": { + hostname: "s3-accesspoint-fips.us-west-2.amazonaws.com", + }, + "fips-us-gov-west-1": { + hostname: "s3-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "s3-external-1": { + hostname: "s3-external-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "sa-east-1": { + hostname: "s3.sa-east-1.amazonaws.com", + }, + "us-east-1": { + hostname: "s3.us-east-1.amazonaws.com", + }, + "us-gov-east-1": { + hostname: "s3.us-gov-east-1.amazonaws.com", + }, + "us-gov-west-1": { + hostname: "s3.us-gov-west-1.amazonaws.com", + }, + "us-west-1": { + hostname: "s3.us-west-1.amazonaws.com", + }, + "us-west-2": { + hostname: "s3.us-west-2.amazonaws.com", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "accesspoint-af-south-1": - regionInfo = { - hostname: "s3-accesspoint.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-ap-east-1": - regionInfo = { - hostname: "s3-accesspoint.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-ap-northeast-1": - regionInfo = { - hostname: "s3-accesspoint.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-ap-northeast-2": - regionInfo = { - hostname: "s3-accesspoint.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-ap-northeast-3": - regionInfo = { - hostname: "s3-accesspoint.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-ap-south-1": - regionInfo = { - hostname: "s3-accesspoint.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-ap-southeast-1": - regionInfo = { - hostname: "s3-accesspoint.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-ap-southeast-2": - regionInfo = { - hostname: "s3-accesspoint.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-ca-central-1": - regionInfo = { - hostname: "s3-accesspoint.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-cn-north-1": - regionInfo = { - hostname: "s3-accesspoint.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "accesspoint-cn-northwest-1": - regionInfo = { - hostname: "s3-accesspoint.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "accesspoint-eu-central-1": - regionInfo = { - hostname: "s3-accesspoint.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-eu-north-1": - regionInfo = { - hostname: "s3-accesspoint.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-eu-south-1": - regionInfo = { - hostname: "s3-accesspoint.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-eu-west-1": - regionInfo = { - hostname: "s3-accesspoint.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-eu-west-2": - regionInfo = { - hostname: "s3-accesspoint.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-eu-west-3": - regionInfo = { - hostname: "s3-accesspoint.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-me-south-1": - regionInfo = { - hostname: "s3-accesspoint.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-sa-east-1": - regionInfo = { - hostname: "s3-accesspoint.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-us-east-1": - regionInfo = { - hostname: "s3-accesspoint.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-us-east-2": - regionInfo = { - hostname: "s3-accesspoint.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-us-gov-east-1": - regionInfo = { - hostname: "s3-accesspoint.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "accesspoint-us-gov-west-1": - regionInfo = { - hostname: "s3-accesspoint.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "accesspoint-us-west-1": - regionInfo = { - hostname: "s3-accesspoint.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "accesspoint-us-west-2": - regionInfo = { - hostname: "s3-accesspoint.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "af-south-1": - regionInfo = { - hostname: "s3.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "s3.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "s3.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "s3.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "s3.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "s3.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "s3.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "s3.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "aws-global": - regionInfo = { - hostname: "s3.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "s3.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "s3.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "s3.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "s3.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "s3.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "s3.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "s3.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "s3.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "s3.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-accesspoint-ca-central-1": - regionInfo = { - hostname: "s3-accesspoint-fips.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "fips-accesspoint-us-east-1": - regionInfo = { - hostname: "s3-accesspoint-fips.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "fips-accesspoint-us-east-2": - regionInfo = { - hostname: "s3-accesspoint-fips.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "fips-accesspoint-us-gov-east-1": - regionInfo = { - hostname: "s3-accesspoint-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "fips-accesspoint-us-gov-west-1": - regionInfo = { - hostname: "s3-accesspoint-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "fips-accesspoint-us-west-1": - regionInfo = { - hostname: "s3-accesspoint-fips.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "fips-accesspoint-us-west-2": - regionInfo = { - hostname: "s3-accesspoint-fips.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "s3-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "s3.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "s3-external-1": - regionInfo = { - hostname: "s3-external-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "s3.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "s3.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "s3.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "s3.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "s3.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "s3.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "s3.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "s3.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "s3.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "s3", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "accesspoint-af-south-1", + "accesspoint-ap-east-1", + "accesspoint-ap-northeast-1", + "accesspoint-ap-northeast-2", + "accesspoint-ap-northeast-3", + "accesspoint-ap-south-1", + "accesspoint-ap-southeast-1", + "accesspoint-ap-southeast-2", + "accesspoint-ca-central-1", + "accesspoint-eu-central-1", + "accesspoint-eu-north-1", + "accesspoint-eu-south-1", + "accesspoint-eu-west-1", + "accesspoint-eu-west-2", + "accesspoint-eu-west-3", + "accesspoint-me-south-1", + "accesspoint-sa-east-1", + "accesspoint-us-east-1", + "accesspoint-us-east-2", + "accesspoint-us-west-1", + "accesspoint-us-west-2", + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-accesspoint-ca-central-1", + "fips-accesspoint-us-east-1", + "fips-accesspoint-us-east-2", + "fips-accesspoint-us-west-1", + "fips-accesspoint-us-west-2", + "me-south-1", + "s3-external-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "s3.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["accesspoint-cn-north-1", "accesspoint-cn-northwest-1", "cn-north-1", "cn-northwest-1"], + hostname: "s3.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "s3.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "s3.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: [ + "accesspoint-us-gov-east-1", + "accesspoint-us-gov-west-1", + "fips-accesspoint-us-gov-east-1", + "fips-accesspoint-us-gov-west-1", + "fips-us-gov-west-1", + "us-gov-east-1", + "us-gov-west-1", + ], + hostname: "s3.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "s3", + regionHash, + partitionHash, + }); diff --git a/clients/client-s3outposts/endpoints.ts b/clients/client-s3outposts/endpoints.ts index 15230dcf8d79b..9f950434ef1b2 100644 --- a/clients/client-s3outposts/endpoints.ts +++ b/clients/client-s3outposts/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "s3-outposts.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "s3-outposts.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "s3-outposts.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "s3-outposts.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "s3-outposts.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "s3-outposts", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "s3-outposts.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "s3-outposts.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "s3-outposts.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "s3-outposts.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "s3-outposts.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "s3-outposts", + regionHash, + partitionHash, + }); diff --git a/clients/client-sagemaker-a2i-runtime/endpoints.ts b/clients/client-sagemaker-a2i-runtime/endpoints.ts index a59ce12e0c35d..dfa086772ecce 100644 --- a/clients/client-sagemaker-a2i-runtime/endpoints.ts +++ b/clients/client-sagemaker-a2i-runtime/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "a2i-runtime.sagemaker.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "a2i-runtime.sagemaker.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "a2i-runtime.sagemaker.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "a2i-runtime.sagemaker.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "a2i-runtime.sagemaker.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "sagemaker", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "a2i-runtime.sagemaker.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "a2i-runtime.sagemaker.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "a2i-runtime.sagemaker.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "a2i-runtime.sagemaker.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "a2i-runtime.sagemaker.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "sagemaker", + regionHash, + partitionHash, + }); diff --git a/clients/client-sagemaker-edge/endpoints.ts b/clients/client-sagemaker-edge/endpoints.ts index f2bc6db898c48..17afe84db899c 100644 --- a/clients/client-sagemaker-edge/endpoints.ts +++ b/clients/client-sagemaker-edge/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "edge.sagemaker.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "edge.sagemaker.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "edge.sagemaker.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "edge.sagemaker.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "edge.sagemaker.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "sagemaker", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "edge.sagemaker.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "edge.sagemaker.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "edge.sagemaker.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "edge.sagemaker.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "edge.sagemaker.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "sagemaker", + regionHash, + partitionHash, + }); diff --git a/clients/client-sagemaker-featurestore-runtime/endpoints.ts b/clients/client-sagemaker-featurestore-runtime/endpoints.ts index a54810342f494..2eab85a6e88e1 100644 --- a/clients/client-sagemaker-featurestore-runtime/endpoints.ts +++ b/clients/client-sagemaker-featurestore-runtime/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "featurestore-runtime.sagemaker.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "featurestore-runtime.sagemaker.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "featurestore-runtime.sagemaker.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "featurestore-runtime.sagemaker.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "featurestore-runtime.sagemaker.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "sagemaker", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "featurestore-runtime.sagemaker.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "featurestore-runtime.sagemaker.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "featurestore-runtime.sagemaker.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "featurestore-runtime.sagemaker.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "featurestore-runtime.sagemaker.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "sagemaker", + regionHash, + partitionHash, + }); diff --git a/clients/client-sagemaker-runtime/endpoints.ts b/clients/client-sagemaker-runtime/endpoints.ts index 2b8ad79195724..a7f674642ff66 100644 --- a/clients/client-sagemaker-runtime/endpoints.ts +++ b/clients/client-sagemaker-runtime/endpoints.ts @@ -1,263 +1,82 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "runtime.sagemaker.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "runtime.sagemaker.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "runtime.sagemaker.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "runtime.sagemaker.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "runtime.sagemaker.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "runtime-fips.sagemaker.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "runtime-fips.sagemaker.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-west-1-fips": { + hostname: "runtime.sagemaker.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "runtime-fips.sagemaker.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "runtime-fips.sagemaker.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "runtime.sagemaker.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "runtime.sagemaker.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "runtime.sagemaker.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "runtime.sagemaker.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "runtime.sagemaker.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "runtime.sagemaker.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "runtime.sagemaker.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "runtime.sagemaker.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "runtime.sagemaker.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "runtime.sagemaker.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "runtime.sagemaker.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "runtime.sagemaker.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "runtime.sagemaker.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "runtime.sagemaker.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "runtime.sagemaker.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "runtime.sagemaker.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "runtime.sagemaker.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "runtime.sagemaker.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "runtime.sagemaker.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "runtime-fips.sagemaker.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "runtime.sagemaker.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "runtime-fips.sagemaker.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "runtime.sagemaker.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "runtime.sagemaker.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "runtime.sagemaker.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "runtime.sagemaker.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "runtime-fips.sagemaker.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "runtime.sagemaker.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "runtime-fips.sagemaker.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "sagemaker", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "runtime.sagemaker.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "runtime.sagemaker.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "runtime.sagemaker.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "runtime.sagemaker.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "runtime.sagemaker.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "sagemaker", + regionHash, + partitionHash, + }); diff --git a/clients/client-sagemaker/endpoints.ts b/clients/client-sagemaker/endpoints.ts index 2a222d4267be1..eaca93f7abde5 100644 --- a/clients/client-sagemaker/endpoints.ts +++ b/clients/client-sagemaker/endpoints.ts @@ -1,270 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "api.sagemaker.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "api.sagemaker.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "api.sagemaker.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "api.sagemaker.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "api.sagemaker.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "api-fips.sagemaker.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "api-fips.sagemaker.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-west-1-fips": { + hostname: "api-fips.sagemaker.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-gov-west-1-fips-secondary": { + hostname: "api.sagemaker.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "api-fips.sagemaker.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "api-fips.sagemaker.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "api.sagemaker.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "api.sagemaker.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "api.sagemaker.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "api.sagemaker.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "api.sagemaker.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "api.sagemaker.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "api.sagemaker.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "api.sagemaker.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "api.sagemaker.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "api.sagemaker.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "api.sagemaker.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "api.sagemaker.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "api.sagemaker.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "api.sagemaker.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "api.sagemaker.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "api.sagemaker.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "api.sagemaker.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "api.sagemaker.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "api.sagemaker.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "api-fips.sagemaker.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "api.sagemaker.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "api-fips.sagemaker.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "api.sagemaker.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "api-fips.sagemaker.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-gov-west-1-fips-secondary": - regionInfo = { - hostname: "api.sagemaker.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "api.sagemaker.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "api.sagemaker.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "api-fips.sagemaker.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "api.sagemaker.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "api-fips.sagemaker.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "sagemaker", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "api.sagemaker.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "api.sagemaker.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "api.sagemaker.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "api.sagemaker.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1", "us-gov-west-1-fips", "us-gov-west-1-fips-secondary"], + hostname: "api.sagemaker.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "sagemaker", + regionHash, + partitionHash, + }); diff --git a/clients/client-savingsplans/endpoints.ts b/clients/client-savingsplans/endpoints.ts index f377110ceac9c..69d4f8c79bef2 100644 --- a/clients/client-savingsplans/endpoints.ts +++ b/clients/client-savingsplans/endpoints.ts @@ -1,85 +1,63 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "savingsplans.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "savingsplans.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "savingsplans.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "savingsplans.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "savingsplans.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-global": { + hostname: "savingsplans.amazonaws.com", + signingRegion: "us-east-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "aws-global": - regionInfo = { - hostname: "savingsplans.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-global"); - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - return defaultRegionInfoProvider("aws-global"); - } - } - return Promise.resolve({ signingService: "savingsplans", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + endpoint: "aws-global", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "savingsplans.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "savingsplans.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "savingsplans.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "savingsplans.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "savingsplans", + regionHash, + partitionHash, + }); diff --git a/clients/client-schemas/endpoints.ts b/clients/client-schemas/endpoints.ts index ae3dee06652be..0dbc5e46a8693 100644 --- a/clients/client-schemas/endpoints.ts +++ b/clients/client-schemas/endpoints.ts @@ -1,186 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "schemas.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "schemas.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "schemas.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "schemas.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "schemas.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "schemas.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "schemas.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "schemas.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "schemas.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "schemas.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "schemas.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "schemas.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "schemas.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "schemas.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "schemas.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "schemas.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "schemas.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "schemas.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "schemas.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "schemas.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "schemas.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "schemas.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "schemas", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "schemas.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "schemas.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "schemas.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "schemas.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "schemas.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "schemas", + regionHash, + partitionHash, + }); diff --git a/clients/client-secrets-manager/endpoints.ts b/clients/client-secrets-manager/endpoints.ts index a56384c3b278a..390beb7c49fa9 100644 --- a/clients/client-secrets-manager/endpoints.ts +++ b/clients/client-secrets-manager/endpoints.ts @@ -1,282 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "secretsmanager.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "secretsmanager.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "secretsmanager.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "secretsmanager.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "secretsmanager.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "secretsmanager-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "secretsmanager-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1-fips": { + hostname: "secretsmanager-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1-fips": { + hostname: "secretsmanager-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "secretsmanager-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "secretsmanager-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "secretsmanager.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "secretsmanager.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "secretsmanager.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "secretsmanager.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "secretsmanager.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "secretsmanager.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "secretsmanager.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "secretsmanager.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "secretsmanager.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "secretsmanager.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "secretsmanager.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "secretsmanager.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "secretsmanager.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "secretsmanager.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "secretsmanager.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "secretsmanager.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "secretsmanager.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "secretsmanager.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "secretsmanager.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "secretsmanager.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "secretsmanager-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "secretsmanager.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "secretsmanager-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "secretsmanager.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-east-1-fips": - regionInfo = { - hostname: "secretsmanager-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "secretsmanager.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "secretsmanager-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "secretsmanager.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "secretsmanager.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "secretsmanager-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "secretsmanager.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "secretsmanager-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "secretsmanager", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "secretsmanager.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "secretsmanager.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "secretsmanager.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "secretsmanager.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-east-1-fips", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "secretsmanager.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "secretsmanager", + regionHash, + partitionHash, + }); diff --git a/clients/client-securityhub/endpoints.ts b/clients/client-securityhub/endpoints.ts index 237cd9dda1b33..17850daddee16 100644 --- a/clients/client-securityhub/endpoints.ts +++ b/clients/client-securityhub/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "securityhub.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "securityhub.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "securityhub.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "securityhub.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "securityhub.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "securityhub-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "securityhub-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "securityhub-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "securityhub-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "securityhub-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "securityhub-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "securityhub.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "securityhub.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "securityhub.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "securityhub.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "securityhub.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "securityhub.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "securityhub.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "securityhub.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "securityhub.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "securityhub.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "securityhub.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "securityhub.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "securityhub.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "securityhub.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "securityhub.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "securityhub.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "securityhub.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "securityhub-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "securityhub-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "securityhub-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "securityhub-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "securityhub-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "securityhub-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "securityhub.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "securityhub.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "securityhub.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "securityhub.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "securityhub.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "securityhub.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "securityhub.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "securityhub.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "securityhub", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "securityhub.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "securityhub.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "securityhub.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "securityhub.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "securityhub.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "securityhub", + regionHash, + partitionHash, + }); diff --git a/clients/client-serverlessapplicationrepository/endpoints.ts b/clients/client-serverlessapplicationrepository/endpoints.ts index fdffd311c1818..b4be65ac5219c 100644 --- a/clients/client-serverlessapplicationrepository/endpoints.ts +++ b/clients/client-serverlessapplicationrepository/endpoints.ts @@ -1,218 +1,66 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "serverlessrepo.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "serverlessrepo.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "serverlessrepo.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "serverlessrepo.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "serverlessrepo.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-gov-east-1": { + hostname: "serverlessrepo.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "serverlessrepo.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "serverlessrepo.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "serverlessrepo.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "serverlessrepo.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "serverlessrepo.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "serverlessrepo.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "serverlessrepo.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "serverlessrepo.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "serverlessrepo.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "serverlessrepo.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "serverlessrepo.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "serverlessrepo.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "serverlessrepo.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "serverlessrepo.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "serverlessrepo.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "serverlessrepo.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "serverlessrepo.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "serverlessrepo.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "serverlessrepo.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "serverlessrepo.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "serverlessrepo.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "serverlessrepo.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "serverlessrepo.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "serverlessrepo", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "serverlessrepo.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "serverlessrepo.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "serverlessrepo.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "serverlessrepo.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "serverlessrepo.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "serverlessrepo", + regionHash, + partitionHash, + }); diff --git a/clients/client-service-catalog-appregistry/endpoints.ts b/clients/client-service-catalog-appregistry/endpoints.ts index bec55b390f002..6fd8187def910 100644 --- a/clients/client-service-catalog-appregistry/endpoints.ts +++ b/clients/client-service-catalog-appregistry/endpoints.ts @@ -1,265 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "servicecatalog-appregistry.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "servicecatalog-appregistry.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "servicecatalog-appregistry.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "servicecatalog-appregistry.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "servicecatalog-appregistry.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "servicecatalog-appregistry-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "servicecatalog-appregistry-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "servicecatalog-appregistry-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "servicecatalog-appregistry.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "servicecatalog-appregistry.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "servicecatalog-appregistry-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "servicecatalog-appregistry-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "servicecatalog-appregistry.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "servicecatalog-appregistry.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "servicecatalog-appregistry.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "servicecatalog-appregistry.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "servicecatalog-appregistry.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "servicecatalog-appregistry.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "servicecatalog-appregistry.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "servicecatalog-appregistry.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "servicecatalog-appregistry.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "servicecatalog-appregistry.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "servicecatalog-appregistry.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "servicecatalog-appregistry.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "servicecatalog-appregistry.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "servicecatalog-appregistry.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "servicecatalog-appregistry-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "servicecatalog-appregistry-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "servicecatalog-appregistry-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "servicecatalog-appregistry.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "servicecatalog-appregistry.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "servicecatalog-appregistry-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "servicecatalog-appregistry-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "servicecatalog-appregistry.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "servicecatalog-appregistry.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "servicecatalog-appregistry.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "servicecatalog-appregistry.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "servicecatalog-appregistry.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "servicecatalog-appregistry.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "servicecatalog-appregistry.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "servicecatalog-appregistry.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "servicecatalog", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "servicecatalog-appregistry.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "servicecatalog-appregistry.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "servicecatalog-appregistry.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "servicecatalog-appregistry.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "servicecatalog-appregistry.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "servicecatalog", + regionHash, + partitionHash, + }); diff --git a/clients/client-service-catalog/endpoints.ts b/clients/client-service-catalog/endpoints.ts index 4e1ca7445e2d5..3aa7d889bf758 100644 --- a/clients/client-service-catalog/endpoints.ts +++ b/clients/client-service-catalog/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "servicecatalog.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "servicecatalog.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "servicecatalog.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "servicecatalog.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "servicecatalog.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "servicecatalog-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "servicecatalog-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1-fips": { + hostname: "servicecatalog-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1-fips": { + hostname: "servicecatalog-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "servicecatalog-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "servicecatalog-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "servicecatalog.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "servicecatalog.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "servicecatalog.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "servicecatalog.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "servicecatalog.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "servicecatalog.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "servicecatalog.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "servicecatalog.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "servicecatalog.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "servicecatalog.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "servicecatalog.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "servicecatalog.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "servicecatalog.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "servicecatalog.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "servicecatalog.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "servicecatalog.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "servicecatalog.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "servicecatalog.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "servicecatalog.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "servicecatalog.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "servicecatalog-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "servicecatalog.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "servicecatalog-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "servicecatalog.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-east-1-fips": - regionInfo = { - hostname: "servicecatalog-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "servicecatalog.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "servicecatalog-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "servicecatalog.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "servicecatalog-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "servicecatalog.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "servicecatalog-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "servicecatalog", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "servicecatalog.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "servicecatalog.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "servicecatalog.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "servicecatalog.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-east-1-fips", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "servicecatalog.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "servicecatalog", + regionHash, + partitionHash, + }); diff --git a/clients/client-service-quotas/endpoints.ts b/clients/client-service-quotas/endpoints.ts index a4d76212ada50..358572161220a 100644 --- a/clients/client-service-quotas/endpoints.ts +++ b/clients/client-service-quotas/endpoints.ts @@ -1,236 +1,66 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "servicequotas.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "servicequotas.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "servicequotas.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "servicequotas.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "servicequotas.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-gov-east-1": { + hostname: "servicequotas.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "servicequotas.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "servicequotas.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "servicequotas.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "servicequotas.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "servicequotas.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "servicequotas.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "servicequotas.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "servicequotas.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "servicequotas.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "servicequotas.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "servicequotas.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "servicequotas.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "servicequotas.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "servicequotas.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "servicequotas.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "servicequotas.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "servicequotas.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "servicequotas.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "servicequotas.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "servicequotas.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "servicequotas.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "servicequotas.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "servicequotas.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "servicequotas.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "servicequotas.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "servicequotas.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "servicequotas", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "servicequotas.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "servicequotas.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "servicequotas.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "servicequotas.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "servicequotas.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "servicequotas", + regionHash, + partitionHash, + }); diff --git a/clients/client-servicediscovery/endpoints.ts b/clients/client-servicediscovery/endpoints.ts index 47c029bee300c..58fa85d86e119 100644 --- a/clients/client-servicediscovery/endpoints.ts +++ b/clients/client-servicediscovery/endpoints.ts @@ -1,223 +1,63 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "servicediscovery.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "servicediscovery.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "servicediscovery.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "servicediscovery.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "servicediscovery.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "servicediscovery-fips": { + hostname: "servicediscovery-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "servicediscovery.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "servicediscovery.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "servicediscovery.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "servicediscovery.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "servicediscovery.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "servicediscovery.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "servicediscovery.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "servicediscovery.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "servicediscovery.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "servicediscovery.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "servicediscovery.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "servicediscovery.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "servicediscovery.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "servicediscovery.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "servicediscovery.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "servicediscovery.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "servicediscovery.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "servicediscovery.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "servicediscovery-fips": - regionInfo = { - hostname: "servicediscovery-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "servicediscovery.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "servicediscovery.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "servicediscovery.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "servicediscovery.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "servicediscovery", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "servicediscovery-fips", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "servicediscovery.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "servicediscovery.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "servicediscovery.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "servicediscovery.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "servicediscovery.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "servicediscovery", + regionHash, + partitionHash, + }); diff --git a/clients/client-ses/endpoints.ts b/clients/client-ses/endpoints.ts index a050ecf2690b7..97e12a6d7fe3b 100644 --- a/clients/client-ses/endpoints.ts +++ b/clients/client-ses/endpoints.ts @@ -1,133 +1,62 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "email.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "email.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "email.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "email.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "email.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-gov-west-1": { + hostname: "email-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-south-1": - regionInfo = { - hostname: "email.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "email.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "email.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "email.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "email-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "email.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "email.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "email.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ses", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "email.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "email.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "email.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "email.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "email.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ses", + regionHash, + partitionHash, + }); diff --git a/clients/client-sesv2/endpoints.ts b/clients/client-sesv2/endpoints.ts index a050ecf2690b7..97e12a6d7fe3b 100644 --- a/clients/client-sesv2/endpoints.ts +++ b/clients/client-sesv2/endpoints.ts @@ -1,133 +1,62 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "email.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "email.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "email.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "email.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "email.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-gov-west-1": { + hostname: "email-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-south-1": - regionInfo = { - hostname: "email.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "email.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "email.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "email.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "email-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "email.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "email.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "email.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ses", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "email.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "email.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "email.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "email.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "email.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ses", + regionHash, + partitionHash, + }); diff --git a/clients/client-sfn/endpoints.ts b/clients/client-sfn/endpoints.ts index 4f644c84799bc..a72b6789d11a5 100644 --- a/clients/client-sfn/endpoints.ts +++ b/clients/client-sfn/endpoints.ts @@ -1,288 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "states.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "states.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "states.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "states.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "states.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "states-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "states-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "states-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "states.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "states-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "states-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "states.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "states.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "states.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "states.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "states.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "states.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "states.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "states.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "states.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "states.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "states.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "states.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "states.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "states.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "states.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "states.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "states.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "states-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "states-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "states-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "states.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "states-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "states-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "states.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "states.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "states.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "states.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "states.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "states.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "states.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "states.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "states.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "states.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "states", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "states.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "states.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "states.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "states.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "states.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "states", + regionHash, + partitionHash, + }); diff --git a/clients/client-shield/endpoints.ts b/clients/client-shield/endpoints.ts index 5f4d38d3833c4..6032e8767813e 100644 --- a/clients/client-shield/endpoints.ts +++ b/clients/client-shield/endpoints.ts @@ -1,92 +1,68 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "shield.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "shield.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "shield.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "shield.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "shield.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-global": { + hostname: "shield.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-aws-global": { + hostname: "shield-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "aws-global": - regionInfo = { - hostname: "shield.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-aws-global": - regionInfo = { - hostname: "shield-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-global"); - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - return defaultRegionInfoProvider("aws-global"); - } - } - return Promise.resolve({ signingService: "shield", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-aws-global", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + endpoint: "aws-global", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "shield.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "shield.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "shield.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "shield.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "shield", + regionHash, + partitionHash, + }); diff --git a/clients/client-signer/endpoints.ts b/clients/client-signer/endpoints.ts index d8f59cdbe39c6..91daff23438c7 100644 --- a/clients/client-signer/endpoints.ts +++ b/clients/client-signer/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "signer.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "signer.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "signer.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "signer.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "signer.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "signer", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "signer.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "signer.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "signer.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "signer.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "signer.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "signer", + regionHash, + partitionHash, + }); diff --git a/clients/client-sms/endpoints.ts b/clients/client-sms/endpoints.ts index c57a7031b0a22..7aac94c860060 100644 --- a/clients/client-sms/endpoints.ts +++ b/clients/client-sms/endpoints.ts @@ -1,270 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "sms.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "sms.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "sms.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "sms.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "sms.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "sms-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "sms-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "sms-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "sms-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "sms-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "sms-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "sms.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "sms.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "sms.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "sms.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "sms.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "sms.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "sms.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "sms.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "sms.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "sms.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "sms.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "sms.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "sms.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "sms.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "sms.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "sms.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "sms-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "sms-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "sms-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "sms-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "sms-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "sms-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "sms.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "sms.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "sms.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "sms.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "sms.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "sms.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "sms.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "sms.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "sms", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "sms.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "sms.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "sms.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "sms.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "sms.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "sms", + regionHash, + partitionHash, + }); diff --git a/clients/client-snow-device-management/endpoints.ts b/clients/client-snow-device-management/endpoints.ts index 4e02cc3442ed2..03e157e7c8c7f 100644 --- a/clients/client-snow-device-management/endpoints.ts +++ b/clients/client-snow-device-management/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "snow-device-management.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "snow-device-management.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "snow-device-management.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "snow-device-management.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "snow-device-management.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "snow-device-management", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "snow-device-management.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "snow-device-management.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "snow-device-management.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "snow-device-management.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "snow-device-management.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "snow-device-management", + regionHash, + partitionHash, + }); diff --git a/clients/client-snowball/endpoints.ts b/clients/client-snowball/endpoints.ts index 40a67e517e04e..9edcf6a7c5559 100644 --- a/clients/client-snowball/endpoints.ts +++ b/clients/client-snowball/endpoints.ts @@ -1,380 +1,154 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "snowball.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "snowball.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "snowball.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "snowball.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "snowball.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ap-northeast-1": { + hostname: "snowball-fips.ap-northeast-1.amazonaws.com", + signingRegion: "ap-northeast-1", + }, + "fips-ap-northeast-2": { + hostname: "snowball-fips.ap-northeast-2.amazonaws.com", + signingRegion: "ap-northeast-2", + }, + "fips-ap-northeast-3": { + hostname: "snowball-fips.ap-northeast-3.amazonaws.com", + signingRegion: "ap-northeast-3", + }, + "fips-ap-south-1": { + hostname: "snowball-fips.ap-south-1.amazonaws.com", + signingRegion: "ap-south-1", + }, + "fips-ap-southeast-1": { + hostname: "snowball-fips.ap-southeast-1.amazonaws.com", + signingRegion: "ap-southeast-1", + }, + "fips-ap-southeast-2": { + hostname: "snowball-fips.ap-southeast-2.amazonaws.com", + signingRegion: "ap-southeast-2", + }, + "fips-ca-central-1": { + hostname: "snowball-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-cn-north-1": { + hostname: "snowball-fips.cn-north-1.amazonaws.com.cn", + signingRegion: "cn-north-1", + }, + "fips-cn-northwest-1": { + hostname: "snowball-fips.cn-northwest-1.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "fips-eu-central-1": { + hostname: "snowball-fips.eu-central-1.amazonaws.com", + signingRegion: "eu-central-1", + }, + "fips-eu-west-1": { + hostname: "snowball-fips.eu-west-1.amazonaws.com", + signingRegion: "eu-west-1", + }, + "fips-eu-west-2": { + hostname: "snowball-fips.eu-west-2.amazonaws.com", + signingRegion: "eu-west-2", + }, + "fips-eu-west-3": { + hostname: "snowball-fips.eu-west-3.amazonaws.com", + signingRegion: "eu-west-3", + }, + "fips-sa-east-1": { + hostname: "snowball-fips.sa-east-1.amazonaws.com", + signingRegion: "sa-east-1", + }, + "fips-us-east-1": { + hostname: "snowball-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "snowball-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "snowball-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "snowball-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "snowball-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "snowball-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "snowball.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "snowball.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "snowball.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "snowball.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "snowball.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "snowball.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "snowball.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "snowball.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "snowball.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "snowball.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "snowball.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "snowball.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "snowball.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "snowball.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "snowball.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "snowball.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "snowball.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ap-northeast-1": - regionInfo = { - hostname: "snowball-fips.ap-northeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-1", - }; - break; - case "fips-ap-northeast-2": - regionInfo = { - hostname: "snowball-fips.ap-northeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-2", - }; - break; - case "fips-ap-northeast-3": - regionInfo = { - hostname: "snowball-fips.ap-northeast-3.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-3", - }; - break; - case "fips-ap-south-1": - regionInfo = { - hostname: "snowball-fips.ap-south-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-south-1", - }; - break; - case "fips-ap-southeast-1": - regionInfo = { - hostname: "snowball-fips.ap-southeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-1", - }; - break; - case "fips-ap-southeast-2": - regionInfo = { - hostname: "snowball-fips.ap-southeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-2", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "snowball-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-cn-north-1": - regionInfo = { - hostname: "snowball-fips.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-north-1", - }; - break; - case "fips-cn-northwest-1": - regionInfo = { - hostname: "snowball-fips.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "fips-eu-central-1": - regionInfo = { - hostname: "snowball-fips.eu-central-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-central-1", - }; - break; - case "fips-eu-west-1": - regionInfo = { - hostname: "snowball-fips.eu-west-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-1", - }; - break; - case "fips-eu-west-2": - regionInfo = { - hostname: "snowball-fips.eu-west-2.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-2", - }; - break; - case "fips-eu-west-3": - regionInfo = { - hostname: "snowball-fips.eu-west-3.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-3", - }; - break; - case "fips-sa-east-1": - regionInfo = { - hostname: "snowball-fips.sa-east-1.amazonaws.com", - partition: "aws", - signingRegion: "sa-east-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "snowball-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "snowball-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "snowball-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "snowball-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "snowball-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "snowball-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "snowball.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "snowball.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "snowball.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "snowball.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "snowball.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "snowball.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "snowball.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "snowball.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "snowball.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "snowball", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ap-northeast-1", + "fips-ap-northeast-2", + "fips-ap-northeast-3", + "fips-ap-south-1", + "fips-ap-southeast-1", + "fips-ap-southeast-2", + "fips-ca-central-1", + "fips-eu-central-1", + "fips-eu-west-1", + "fips-eu-west-2", + "fips-eu-west-3", + "fips-sa-east-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "snowball.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1", "fips-cn-north-1", "fips-cn-northwest-1"], + hostname: "snowball.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "snowball.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "snowball.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "snowball.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "snowball", + regionHash, + partitionHash, + }); diff --git a/clients/client-sns/endpoints.ts b/clients/client-sns/endpoints.ts index 4d8057ca3a793..c91b89c1c1e4e 100644 --- a/clients/client-sns/endpoints.ts +++ b/clients/client-sns/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "sns.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "sns.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "sns.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "sns.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "sns.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "sns-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "sns-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "sns-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "sns-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "sns.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "sns.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "sns.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "sns.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "sns.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "sns.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "sns.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "sns.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "sns.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "sns.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "sns.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "sns.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "sns.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "sns.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "sns.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "sns.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "sns.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "sns.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "sns.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "sns-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "sns-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "sns-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "sns-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "sns.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "sns.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "sns.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "sns.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "sns.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "sns.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "sns.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "sns.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "sns.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "sns.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "sns", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "sns.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "sns.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "sns.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "sns.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "sns.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "sns", + regionHash, + partitionHash, + }); diff --git a/clients/client-sqs/endpoints.ts b/clients/client-sqs/endpoints.ts index 043a98a9bb4cc..0a36c50323e89 100644 --- a/clients/client-sqs/endpoints.ts +++ b/clients/client-sqs/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "sqs.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "sqs.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "sqs.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "sqs.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "sqs.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "sqs-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "sqs-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "sqs-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "sqs-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "sqs.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "sqs.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "sqs.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "sqs.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "sqs.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "sqs.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "sqs.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "sqs.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "sqs.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "sqs.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "sqs.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "sqs.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "sqs.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "sqs.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "sqs.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "sqs.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "sqs.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "sqs.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "sqs.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "sqs-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "sqs-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "sqs-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "sqs-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "sqs.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "sqs.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "sqs.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "sqs.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "sqs.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "sqs.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "sqs.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "sqs.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "sqs.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "sqs.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "sqs", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "sqs.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "sqs.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "sqs.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "sqs.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "sqs.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "sqs", + regionHash, + partitionHash, + }); diff --git a/clients/client-ssm-contacts/endpoints.ts b/clients/client-ssm-contacts/endpoints.ts index 1ca21895f2259..0fe8a287eb145 100644 --- a/clients/client-ssm-contacts/endpoints.ts +++ b/clients/client-ssm-contacts/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "ssm-contacts.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "ssm-contacts.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "ssm-contacts.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "ssm-contacts.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "ssm-contacts.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ssm-contacts", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "ssm-contacts.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "ssm-contacts.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "ssm-contacts.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "ssm-contacts.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "ssm-contacts.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ssm-contacts", + regionHash, + partitionHash, + }); diff --git a/clients/client-ssm-incidents/endpoints.ts b/clients/client-ssm-incidents/endpoints.ts index be896425630e3..77e5b964eaa51 100644 --- a/clients/client-ssm-incidents/endpoints.ts +++ b/clients/client-ssm-incidents/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "ssm-incidents.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "ssm-incidents.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "ssm-incidents.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "ssm-incidents.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "ssm-incidents.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ssm-incidents", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "ssm-incidents.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "ssm-incidents.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "ssm-incidents.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "ssm-incidents.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "ssm-incidents.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ssm-incidents", + regionHash, + partitionHash, + }); diff --git a/clients/client-ssm/endpoints.ts b/clients/client-ssm/endpoints.ts index 097d0a25d5252..6ed0aab46e2a4 100644 --- a/clients/client-ssm/endpoints.ts +++ b/clients/client-ssm/endpoints.ts @@ -1,295 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "ssm.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "ssm.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "ssm.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "ssm.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "ssm.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "ssm-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "ssm-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "ssm-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "ssm.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "ssm.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "ssm-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "ssm-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "ssm.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "ssm.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "ssm.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "ssm.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "ssm.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "ssm.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "ssm.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "ssm.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "ssm.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "ssm.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "ssm.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "ssm.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "ssm.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "ssm.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "ssm.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "ssm.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "ssm.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "ssm-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "ssm-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "ssm-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "ssm.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "ssm.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "ssm-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "ssm-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "ssm.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "ssm.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "ssm.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "ssm.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "ssm.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "ssm.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "ssm.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "ssm.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "ssm.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "ssm.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "ssm", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "ssm.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "ssm.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "ssm.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "ssm.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "ssm.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "ssm", + regionHash, + partitionHash, + }); diff --git a/clients/client-sso-admin/endpoints.ts b/clients/client-sso-admin/endpoints.ts index 983325f27fb63..862e3d0968a71 100644 --- a/clients/client-sso-admin/endpoints.ts +++ b/clients/client-sso-admin/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "sso.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "sso.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "sso.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "sso.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "sso.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "sso", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "sso.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "sso.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "sso.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "sso.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "sso.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "sso", + regionHash, + partitionHash, + }); diff --git a/clients/client-sso-oidc/endpoints.ts b/clients/client-sso-oidc/endpoints.ts index 99c2223b1a4a6..2f827748797ca 100644 --- a/clients/client-sso-oidc/endpoints.ts +++ b/clients/client-sso-oidc/endpoints.ts @@ -1,182 +1,114 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "oidc.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "oidc.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "oidc.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "oidc.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "oidc.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "ap-northeast-1": { + hostname: "oidc.ap-northeast-1.amazonaws.com", + signingRegion: "ap-northeast-1", + }, + "ap-northeast-2": { + hostname: "oidc.ap-northeast-2.amazonaws.com", + signingRegion: "ap-northeast-2", + }, + "ap-south-1": { + hostname: "oidc.ap-south-1.amazonaws.com", + signingRegion: "ap-south-1", + }, + "ap-southeast-1": { + hostname: "oidc.ap-southeast-1.amazonaws.com", + signingRegion: "ap-southeast-1", + }, + "ap-southeast-2": { + hostname: "oidc.ap-southeast-2.amazonaws.com", + signingRegion: "ap-southeast-2", + }, + "ca-central-1": { + hostname: "oidc.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "eu-central-1": { + hostname: "oidc.eu-central-1.amazonaws.com", + signingRegion: "eu-central-1", + }, + "eu-north-1": { + hostname: "oidc.eu-north-1.amazonaws.com", + signingRegion: "eu-north-1", + }, + "eu-west-1": { + hostname: "oidc.eu-west-1.amazonaws.com", + signingRegion: "eu-west-1", + }, + "eu-west-2": { + hostname: "oidc.eu-west-2.amazonaws.com", + signingRegion: "eu-west-2", + }, + "eu-west-3": { + hostname: "oidc.eu-west-3.amazonaws.com", + signingRegion: "eu-west-3", + }, + "us-east-1": { + hostname: "oidc.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2": { + hostname: "oidc.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-west-2": { + hostname: "oidc.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "oidc.ap-northeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-1", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "oidc.ap-northeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-2", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "oidc.ap-south-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-south-1", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "oidc.ap-southeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-1", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "oidc.ap-southeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-2", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "oidc.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "oidc.eu-central-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-central-1", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "oidc.eu-north-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-north-1", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "oidc.eu-west-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-1", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "oidc.eu-west-2.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-2", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "oidc.eu-west-3.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-3", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "oidc.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "oidc.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "oidc.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "awsssooidc", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "oidc.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "oidc.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "oidc.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "oidc.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "oidc.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "awsssooidc", + regionHash, + partitionHash, + }); diff --git a/clients/client-sso/endpoints.ts b/clients/client-sso/endpoints.ts index ffb127f6fb3cb..b369a3679af63 100644 --- a/clients/client-sso/endpoints.ts +++ b/clients/client-sso/endpoints.ts @@ -1,147 +1,94 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "portal.sso.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "portal.sso.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "portal.sso.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "portal.sso.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "portal.sso.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "ap-southeast-1": { + hostname: "portal.sso.ap-southeast-1.amazonaws.com", + signingRegion: "ap-southeast-1", + }, + "ap-southeast-2": { + hostname: "portal.sso.ap-southeast-2.amazonaws.com", + signingRegion: "ap-southeast-2", + }, + "ca-central-1": { + hostname: "portal.sso.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "eu-central-1": { + hostname: "portal.sso.eu-central-1.amazonaws.com", + signingRegion: "eu-central-1", + }, + "eu-west-1": { + hostname: "portal.sso.eu-west-1.amazonaws.com", + signingRegion: "eu-west-1", + }, + "eu-west-2": { + hostname: "portal.sso.eu-west-2.amazonaws.com", + signingRegion: "eu-west-2", + }, + "us-east-1": { + hostname: "portal.sso.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2": { + hostname: "portal.sso.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-west-2": { + hostname: "portal.sso.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-southeast-1": - regionInfo = { - hostname: "portal.sso.ap-southeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-1", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "portal.sso.ap-southeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-2", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "portal.sso.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "portal.sso.eu-central-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-central-1", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "portal.sso.eu-west-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-1", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "portal.sso.eu-west-2.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "portal.sso.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "portal.sso.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "portal.sso.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "awsssoportal", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "portal.sso.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "portal.sso.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "portal.sso.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "portal.sso.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "portal.sso.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "awsssoportal", + regionHash, + partitionHash, + }); diff --git a/clients/client-storage-gateway/endpoints.ts b/clients/client-storage-gateway/endpoints.ts index bad99e9d0c176..0adef6859e39b 100644 --- a/clients/client-storage-gateway/endpoints.ts +++ b/clients/client-storage-gateway/endpoints.ts @@ -1,241 +1,63 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "storagegateway.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "storagegateway.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "storagegateway.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "storagegateway.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "storagegateway.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + fips: { + hostname: "storagegateway-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "storagegateway.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "storagegateway.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "storagegateway.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "storagegateway.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "storagegateway.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "storagegateway.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "storagegateway.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "storagegateway.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "storagegateway.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "storagegateway.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "storagegateway.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "storagegateway.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "storagegateway.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "storagegateway.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "storagegateway.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "storagegateway.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "storagegateway.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips": - regionInfo = { - hostname: "storagegateway-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "storagegateway.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "storagegateway.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "storagegateway.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "storagegateway.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "storagegateway.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "storagegateway.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "storagegateway.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "storagegateway.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "storagegateway", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "storagegateway.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "storagegateway.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "storagegateway.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "storagegateway.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips", "us-gov-east-1", "us-gov-west-1"], + hostname: "storagegateway.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "storagegateway", + regionHash, + partitionHash, + }); diff --git a/clients/client-sts/endpoints.ts b/clients/client-sts/endpoints.ts index 14963ee5e4e1b..d475338a16107 100644 --- a/clients/client-sts/endpoints.ts +++ b/clients/client-sts/endpoints.ts @@ -1,295 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "sts.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "sts.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "sts.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "sts.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "sts.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-global": { + hostname: "sts.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-1-fips": { + hostname: "sts-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "sts-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1-fips": { + hostname: "sts.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1-fips": { + hostname: "sts.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1-fips": { + hostname: "sts-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2-fips": { + hostname: "sts-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "sts.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "sts.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "sts.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "sts.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "sts.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "sts.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "sts.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "sts.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "aws-global": - regionInfo = { - hostname: "sts.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "sts.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "sts.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "sts.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "sts.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "sts.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "sts.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "sts.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "sts.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "sts.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "sts.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "sts.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "sts.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "sts-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "sts.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "sts-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "sts.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-east-1-fips": - regionInfo = { - hostname: "sts.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "sts.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "sts.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "sts.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "sts.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "sts.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-1-fips": - regionInfo = { - hostname: "sts-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "sts.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "sts-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "sts", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-1-fips", + "us-west-2", + "us-west-2-fips", + ], + hostname: "sts.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "sts.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "sts.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "sts.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-east-1-fips", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "sts.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "sts", + regionHash, + partitionHash, + }); diff --git a/clients/client-support/endpoints.ts b/clients/client-support/endpoints.ts index e5e5dad8f4b67..b971640571ac3 100644 --- a/clients/client-support/endpoints.ts +++ b/clients/client-support/endpoints.ts @@ -1,126 +1,83 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "support.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "support.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "support.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "support.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "support.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-cn-global": { + hostname: "support.cn-north-1.amazonaws.com.cn", + signingRegion: "cn-north-1", + }, + "aws-global": { + hostname: "support.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "aws-iso-b-global": { + hostname: "support.us-isob-east-1.sc2s.sgov.gov", + signingRegion: "us-isob-east-1", + }, + "aws-iso-global": { + hostname: "support.us-iso-east-1.c2s.ic.gov", + signingRegion: "us-iso-east-1", + }, + "aws-us-gov-global": { + hostname: "support.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-gov-west-1": { + hostname: "support.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "aws-cn-global": - regionInfo = { - hostname: "support.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-north-1", - }; - break; - case "aws-global": - regionInfo = { - hostname: "support.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "aws-iso-b-global": - regionInfo = { - hostname: "support.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - signingRegion: "us-isob-east-1", - }; - break; - case "aws-iso-global": - regionInfo = { - hostname: "support.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - signingRegion: "us-iso-east-1", - }; - break; - case "aws-us-gov-global": - regionInfo = { - hostname: "support.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "support.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "support", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "support.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["aws-cn-global", "cn-north-1", "cn-northwest-1"], + hostname: "support.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["aws-iso-global", "us-iso-east-1"], + hostname: "support.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["aws-iso-b-global", "us-isob-east-1"], + hostname: "support.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["aws-us-gov-global", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "support.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "support", + regionHash, + partitionHash, + }); diff --git a/clients/client-swf/endpoints.ts b/clients/client-swf/endpoints.ts index 5615ad956c3f7..69089cbd1a970 100644 --- a/clients/client-swf/endpoints.ts +++ b/clients/client-swf/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "swf.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "swf.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "swf.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "swf.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "swf.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "swf-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "swf-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-west-1": { + hostname: "swf-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "swf-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "us-gov-east-1": { + hostname: "swf.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "swf.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "swf.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "swf.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "swf.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "swf.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "swf.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "swf.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "swf.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "swf.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "swf.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "swf.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "swf.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "swf.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "swf.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "swf.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "swf.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "swf.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "swf.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "swf-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "swf-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "swf-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "swf-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "swf.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "swf.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "swf.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "swf.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "swf.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "swf.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "swf.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-isob-east-1": - regionInfo = { - hostname: "swf.us-isob-east-1.sc2s.sgov.gov", - partition: "aws-iso-b", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "swf.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "swf.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "swf", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "swf.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "swf.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "swf.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "swf.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "swf.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "swf", + regionHash, + partitionHash, + }); diff --git a/clients/client-synthetics/endpoints.ts b/clients/client-synthetics/endpoints.ts index 2fc03dd50d7b8..69cdf793447bc 100644 --- a/clients/client-synthetics/endpoints.ts +++ b/clients/client-synthetics/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "synthetics.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "synthetics.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "synthetics.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "synthetics.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "synthetics.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "synthetics", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "synthetics.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "synthetics.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "synthetics.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "synthetics.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "synthetics.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "synthetics", + regionHash, + partitionHash, + }); diff --git a/clients/client-textract/endpoints.ts b/clients/client-textract/endpoints.ts index 362920b3c9ada..bdc667a63ea20 100644 --- a/clients/client-textract/endpoints.ts +++ b/clients/client-textract/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "textract.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "textract.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "textract.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "textract.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "textract.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "textract", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "textract.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "textract.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "textract.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "textract.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "textract.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "textract", + regionHash, + partitionHash, + }); diff --git a/clients/client-timestream-query/endpoints.ts b/clients/client-timestream-query/endpoints.ts index 869b9785f99d4..32c8550b54721 100644 --- a/clients/client-timestream-query/endpoints.ts +++ b/clients/client-timestream-query/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "query.timestream.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "query.timestream.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "query.timestream.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "query.timestream.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "query.timestream.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "timestream", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "query.timestream.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "query.timestream.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "query.timestream.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "query.timestream.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "query.timestream.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "timestream", + regionHash, + partitionHash, + }); diff --git a/clients/client-timestream-write/endpoints.ts b/clients/client-timestream-write/endpoints.ts index 74d362311216f..4b3660aa96930 100644 --- a/clients/client-timestream-write/endpoints.ts +++ b/clients/client-timestream-write/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "ingest.timestream.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "ingest.timestream.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "ingest.timestream.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "ingest.timestream.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "ingest.timestream.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "timestream", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "ingest.timestream.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "ingest.timestream.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "ingest.timestream.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "ingest.timestream.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "ingest.timestream.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "timestream", + regionHash, + partitionHash, + }); diff --git a/clients/client-transcribe-streaming/endpoints.ts b/clients/client-transcribe-streaming/endpoints.ts index 857feaf5b1c2d..59e2a04cbdfcc 100644 --- a/clients/client-transcribe-streaming/endpoints.ts +++ b/clients/client-transcribe-streaming/endpoints.ts @@ -1,168 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "transcribestreaming.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "transcribestreaming.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "transcribestreaming.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "transcribestreaming.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "transcribestreaming.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "transcribestreaming.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "transcribestreaming.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "transcribestreaming.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "transcribestreaming.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "transcribestreaming.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "transcribestreaming.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "transcribestreaming.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "transcribestreaming.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "transcribestreaming.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "transcribestreaming.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "transcribestreaming.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "transcribestreaming.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "transcribestreaming.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "transcribestreaming.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "transcribe", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "transcribestreaming.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "transcribestreaming.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "transcribestreaming.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "transcribestreaming.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "transcribestreaming.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "transcribe", + regionHash, + partitionHash, + }); diff --git a/clients/client-transcribe/endpoints.ts b/clients/client-transcribe/endpoints.ts index 3541a2da845f0..2d2712d6e7870 100644 --- a/clients/client-transcribe/endpoints.ts +++ b/clients/client-transcribe/endpoints.ts @@ -1,260 +1,94 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "transcribe.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "transcribe.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "transcribe.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "transcribe.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "transcribe.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "cn-north-1": { + hostname: "cn.transcribe.cn-north-1.amazonaws.com.cn", + signingRegion: "cn-north-1", + }, + "cn-northwest-1": { + hostname: "cn.transcribe.cn-northwest-1.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "fips-us-east-1": { + hostname: "fips.transcribe.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "fips.transcribe.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "fips.transcribe.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "fips.transcribe.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "fips.transcribe.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "fips.transcribe.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "transcribe.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "transcribe.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "transcribe.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "transcribe.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "transcribe.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "transcribe.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "transcribe.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "cn.transcribe.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-north-1", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "cn.transcribe.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "transcribe.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "transcribe.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "transcribe.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "transcribe.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "fips.transcribe.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "fips.transcribe.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "fips.transcribe.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "fips.transcribe.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "fips.transcribe.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "fips.transcribe.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "transcribe.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "transcribe.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "transcribe.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "transcribe.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "transcribe.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "transcribe.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "transcribe.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "transcribe.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "transcribe.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "transcribe", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "transcribe.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "transcribe.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "transcribe.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "transcribe.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "transcribe.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "transcribe", + regionHash, + partitionHash, + }); diff --git a/clients/client-transfer/endpoints.ts b/clients/client-transfer/endpoints.ts index 4a61d66c75c97..5aa82d2f5460d 100644 --- a/clients/client-transfer/endpoints.ts +++ b/clients/client-transfer/endpoints.ts @@ -1,277 +1,91 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "transfer.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "transfer.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "transfer.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "transfer.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "transfer.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-ca-central-1": { + hostname: "transfer-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-us-east-1": { + hostname: "transfer-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "transfer-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "transfer-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "transfer-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "transfer-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "transfer-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "transfer.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "transfer.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "transfer.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "transfer.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "transfer.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "transfer.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "transfer.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "transfer.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "transfer.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "transfer.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "transfer.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "transfer.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "transfer.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "transfer.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "transfer.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "transfer.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "transfer-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "transfer-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "transfer-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "transfer-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "transfer-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "transfer-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "transfer-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "transfer.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "transfer.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "transfer.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "transfer.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "transfer.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "transfer.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "transfer.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "transfer.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "transfer", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-ca-central-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "transfer.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "transfer.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "transfer.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "transfer.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "transfer.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "transfer", + regionHash, + partitionHash, + }); diff --git a/clients/client-translate/endpoints.ts b/clients/client-translate/endpoints.ts index cd31f8be53457..bdecb30b3e473 100644 --- a/clients/client-translate/endpoints.ts +++ b/clients/client-translate/endpoints.ts @@ -1,220 +1,77 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "translate.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "translate.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "translate.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "translate.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "translate.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "us-east-1-fips": { + hostname: "translate-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2-fips": { + hostname: "translate-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-west-1-fips": { + hostname: "translate-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-2-fips": { + hostname: "translate-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-east-1": - regionInfo = { - hostname: "translate.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "translate.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "translate.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "translate.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "translate.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "translate.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "translate.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "translate.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "translate.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "translate.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "translate.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "translate.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "translate.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1-fips": - regionInfo = { - hostname: "translate-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "translate.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2-fips": - regionInfo = { - hostname: "translate-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "translate.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1-fips": - regionInfo = { - hostname: "translate-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "translate.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "translate.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "translate.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2-fips": - regionInfo = { - hostname: "translate-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "translate", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-1-fips", + "us-east-2", + "us-east-2-fips", + "us-west-1", + "us-west-2", + "us-west-2-fips", + ], + hostname: "translate.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "translate.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "translate.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "translate.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1", "us-gov-west-1-fips"], + hostname: "translate.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "translate", + regionHash, + partitionHash, + }); diff --git a/clients/client-waf-regional/endpoints.ts b/clients/client-waf-regional/endpoints.ts index f6a6760f5242b..fe71350e98a56 100644 --- a/clients/client-waf-regional/endpoints.ts +++ b/clients/client-waf-regional/endpoints.ts @@ -1,434 +1,279 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "waf-regional.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "waf-regional.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "waf-regional.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "waf-regional.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "waf-regional.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "af-south-1": { + hostname: "waf-regional.af-south-1.amazonaws.com", + signingRegion: "af-south-1", + }, + "ap-east-1": { + hostname: "waf-regional.ap-east-1.amazonaws.com", + signingRegion: "ap-east-1", + }, + "ap-northeast-1": { + hostname: "waf-regional.ap-northeast-1.amazonaws.com", + signingRegion: "ap-northeast-1", + }, + "ap-northeast-2": { + hostname: "waf-regional.ap-northeast-2.amazonaws.com", + signingRegion: "ap-northeast-2", + }, + "ap-northeast-3": { + hostname: "waf-regional.ap-northeast-3.amazonaws.com", + signingRegion: "ap-northeast-3", + }, + "ap-south-1": { + hostname: "waf-regional.ap-south-1.amazonaws.com", + signingRegion: "ap-south-1", + }, + "ap-southeast-1": { + hostname: "waf-regional.ap-southeast-1.amazonaws.com", + signingRegion: "ap-southeast-1", + }, + "ap-southeast-2": { + hostname: "waf-regional.ap-southeast-2.amazonaws.com", + signingRegion: "ap-southeast-2", + }, + "ca-central-1": { + hostname: "waf-regional.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "cn-north-1": { + hostname: "waf-regional.cn-north-1.amazonaws.com.cn", + signingRegion: "cn-north-1", + }, + "cn-northwest-1": { + hostname: "waf-regional.cn-northwest-1.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "eu-central-1": { + hostname: "waf-regional.eu-central-1.amazonaws.com", + signingRegion: "eu-central-1", + }, + "eu-north-1": { + hostname: "waf-regional.eu-north-1.amazonaws.com", + signingRegion: "eu-north-1", + }, + "eu-south-1": { + hostname: "waf-regional.eu-south-1.amazonaws.com", + signingRegion: "eu-south-1", + }, + "eu-west-1": { + hostname: "waf-regional.eu-west-1.amazonaws.com", + signingRegion: "eu-west-1", + }, + "eu-west-2": { + hostname: "waf-regional.eu-west-2.amazonaws.com", + signingRegion: "eu-west-2", + }, + "eu-west-3": { + hostname: "waf-regional.eu-west-3.amazonaws.com", + signingRegion: "eu-west-3", + }, + "fips-af-south-1": { + hostname: "waf-regional-fips.af-south-1.amazonaws.com", + signingRegion: "af-south-1", + }, + "fips-ap-east-1": { + hostname: "waf-regional-fips.ap-east-1.amazonaws.com", + signingRegion: "ap-east-1", + }, + "fips-ap-northeast-1": { + hostname: "waf-regional-fips.ap-northeast-1.amazonaws.com", + signingRegion: "ap-northeast-1", + }, + "fips-ap-northeast-2": { + hostname: "waf-regional-fips.ap-northeast-2.amazonaws.com", + signingRegion: "ap-northeast-2", + }, + "fips-ap-northeast-3": { + hostname: "waf-regional-fips.ap-northeast-3.amazonaws.com", + signingRegion: "ap-northeast-3", + }, + "fips-ap-south-1": { + hostname: "waf-regional-fips.ap-south-1.amazonaws.com", + signingRegion: "ap-south-1", + }, + "fips-ap-southeast-1": { + hostname: "waf-regional-fips.ap-southeast-1.amazonaws.com", + signingRegion: "ap-southeast-1", + }, + "fips-ap-southeast-2": { + hostname: "waf-regional-fips.ap-southeast-2.amazonaws.com", + signingRegion: "ap-southeast-2", + }, + "fips-ca-central-1": { + hostname: "waf-regional-fips.ca-central-1.amazonaws.com", + signingRegion: "ca-central-1", + }, + "fips-cn-north-1": { + hostname: "waf-regional-fips.cn-north-1.amazonaws.com.cn", + signingRegion: "cn-north-1", + }, + "fips-cn-northwest-1": { + hostname: "waf-regional-fips.cn-northwest-1.amazonaws.com.cn", + signingRegion: "cn-northwest-1", + }, + "fips-eu-central-1": { + hostname: "waf-regional-fips.eu-central-1.amazonaws.com", + signingRegion: "eu-central-1", + }, + "fips-eu-north-1": { + hostname: "waf-regional-fips.eu-north-1.amazonaws.com", + signingRegion: "eu-north-1", + }, + "fips-eu-south-1": { + hostname: "waf-regional-fips.eu-south-1.amazonaws.com", + signingRegion: "eu-south-1", + }, + "fips-eu-west-1": { + hostname: "waf-regional-fips.eu-west-1.amazonaws.com", + signingRegion: "eu-west-1", + }, + "fips-eu-west-2": { + hostname: "waf-regional-fips.eu-west-2.amazonaws.com", + signingRegion: "eu-west-2", + }, + "fips-eu-west-3": { + hostname: "waf-regional-fips.eu-west-3.amazonaws.com", + signingRegion: "eu-west-3", + }, + "fips-me-south-1": { + hostname: "waf-regional-fips.me-south-1.amazonaws.com", + signingRegion: "me-south-1", + }, + "fips-sa-east-1": { + hostname: "waf-regional-fips.sa-east-1.amazonaws.com", + signingRegion: "sa-east-1", + }, + "fips-us-east-1": { + hostname: "waf-regional-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "waf-regional-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "waf-regional-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "waf-regional-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "waf-regional-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "waf-regional-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, + "me-south-1": { + hostname: "waf-regional.me-south-1.amazonaws.com", + signingRegion: "me-south-1", + }, + "sa-east-1": { + hostname: "waf-regional.sa-east-1.amazonaws.com", + signingRegion: "sa-east-1", + }, + "us-east-1": { + hostname: "waf-regional.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "us-east-2": { + hostname: "waf-regional.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "us-gov-east-1": { + hostname: "waf-regional.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "us-gov-west-1": { + hostname: "waf-regional.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "us-west-1": { + hostname: "waf-regional.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "us-west-2": { + hostname: "waf-regional.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "waf-regional.af-south-1.amazonaws.com", - partition: "aws", - signingRegion: "af-south-1", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "waf-regional.ap-east-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-east-1", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "waf-regional.ap-northeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-1", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "waf-regional.ap-northeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-2", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "waf-regional.ap-northeast-3.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-3", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "waf-regional.ap-south-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-south-1", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "waf-regional.ap-southeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-1", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "waf-regional.ap-southeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-2", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "waf-regional.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "waf-regional.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-north-1", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "waf-regional.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "waf-regional.eu-central-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-central-1", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "waf-regional.eu-north-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-north-1", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "waf-regional.eu-south-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-south-1", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "waf-regional.eu-west-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-1", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "waf-regional.eu-west-2.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-2", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "waf-regional.eu-west-3.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-3", - }; - break; - case "fips-af-south-1": - regionInfo = { - hostname: "waf-regional-fips.af-south-1.amazonaws.com", - partition: "aws", - signingRegion: "af-south-1", - }; - break; - case "fips-ap-east-1": - regionInfo = { - hostname: "waf-regional-fips.ap-east-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-east-1", - }; - break; - case "fips-ap-northeast-1": - regionInfo = { - hostname: "waf-regional-fips.ap-northeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-1", - }; - break; - case "fips-ap-northeast-2": - regionInfo = { - hostname: "waf-regional-fips.ap-northeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-2", - }; - break; - case "fips-ap-northeast-3": - regionInfo = { - hostname: "waf-regional-fips.ap-northeast-3.amazonaws.com", - partition: "aws", - signingRegion: "ap-northeast-3", - }; - break; - case "fips-ap-south-1": - regionInfo = { - hostname: "waf-regional-fips.ap-south-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-south-1", - }; - break; - case "fips-ap-southeast-1": - regionInfo = { - hostname: "waf-regional-fips.ap-southeast-1.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-1", - }; - break; - case "fips-ap-southeast-2": - regionInfo = { - hostname: "waf-regional-fips.ap-southeast-2.amazonaws.com", - partition: "aws", - signingRegion: "ap-southeast-2", - }; - break; - case "fips-ca-central-1": - regionInfo = { - hostname: "waf-regional-fips.ca-central-1.amazonaws.com", - partition: "aws", - signingRegion: "ca-central-1", - }; - break; - case "fips-cn-north-1": - regionInfo = { - hostname: "waf-regional-fips.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-north-1", - }; - break; - case "fips-cn-northwest-1": - regionInfo = { - hostname: "waf-regional-fips.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - signingRegion: "cn-northwest-1", - }; - break; - case "fips-eu-central-1": - regionInfo = { - hostname: "waf-regional-fips.eu-central-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-central-1", - }; - break; - case "fips-eu-north-1": - regionInfo = { - hostname: "waf-regional-fips.eu-north-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-north-1", - }; - break; - case "fips-eu-south-1": - regionInfo = { - hostname: "waf-regional-fips.eu-south-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-south-1", - }; - break; - case "fips-eu-west-1": - regionInfo = { - hostname: "waf-regional-fips.eu-west-1.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-1", - }; - break; - case "fips-eu-west-2": - regionInfo = { - hostname: "waf-regional-fips.eu-west-2.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-2", - }; - break; - case "fips-eu-west-3": - regionInfo = { - hostname: "waf-regional-fips.eu-west-3.amazonaws.com", - partition: "aws", - signingRegion: "eu-west-3", - }; - break; - case "fips-me-south-1": - regionInfo = { - hostname: "waf-regional-fips.me-south-1.amazonaws.com", - partition: "aws", - signingRegion: "me-south-1", - }; - break; - case "fips-sa-east-1": - regionInfo = { - hostname: "waf-regional-fips.sa-east-1.amazonaws.com", - partition: "aws", - signingRegion: "sa-east-1", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "waf-regional-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "waf-regional-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "waf-regional-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "waf-regional-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "waf-regional-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "waf-regional-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "waf-regional.me-south-1.amazonaws.com", - partition: "aws", - signingRegion: "me-south-1", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "waf-regional.sa-east-1.amazonaws.com", - partition: "aws", - signingRegion: "sa-east-1", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "waf-regional.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "waf-regional.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "waf-regional.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "waf-regional.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "waf-regional.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "waf-regional.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "waf-regional", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-af-south-1", + "fips-ap-east-1", + "fips-ap-northeast-1", + "fips-ap-northeast-2", + "fips-ap-northeast-3", + "fips-ap-south-1", + "fips-ap-southeast-1", + "fips-ap-southeast-2", + "fips-ca-central-1", + "fips-eu-central-1", + "fips-eu-north-1", + "fips-eu-south-1", + "fips-eu-west-1", + "fips-eu-west-2", + "fips-eu-west-3", + "fips-me-south-1", + "fips-sa-east-1", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "waf-regional.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1", "fips-cn-north-1", "fips-cn-northwest-1"], + hostname: "waf-regional.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "waf-regional.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "waf-regional.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "waf-regional.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "waf-regional", + regionHash, + partitionHash, + }); diff --git a/clients/client-waf/endpoints.ts b/clients/client-waf/endpoints.ts index ef4a8dca4e94e..6741a8b4c2ba3 100644 --- a/clients/client-waf/endpoints.ts +++ b/clients/client-waf/endpoints.ts @@ -1,92 +1,68 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "waf.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "waf.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "waf.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "waf.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "waf.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "aws-fips": { + hostname: "waf-fips.amazonaws.com", + signingRegion: "us-east-1", + }, + "aws-global": { + hostname: "waf.amazonaws.com", + signingRegion: "us-east-1", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "aws-fips": - regionInfo = { - hostname: "waf-fips.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "aws-global": - regionInfo = { - hostname: "waf.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - return defaultRegionInfoProvider("aws-global"); - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - return defaultRegionInfoProvider("aws-global"); - } - } - return Promise.resolve({ signingService: "waf", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "aws-fips", + "aws-global", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + endpoint: "aws-global", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "waf.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "waf.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "waf.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "waf.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "waf", + regionHash, + partitionHash, + }); diff --git a/clients/client-wafv2/endpoints.ts b/clients/client-wafv2/endpoints.ts index 5760d6c459ef3..0421963660cdf 100644 --- a/clients/client-wafv2/endpoints.ts +++ b/clients/client-wafv2/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "wafv2.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "wafv2.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "wafv2.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "wafv2.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "wafv2.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "wafv2", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "wafv2.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "wafv2.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "wafv2.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "wafv2.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "wafv2.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "wafv2", + regionHash, + partitionHash, + }); diff --git a/clients/client-wellarchitected/endpoints.ts b/clients/client-wellarchitected/endpoints.ts index d0279c3b23436..4502620e66e82 100644 --- a/clients/client-wellarchitected/endpoints.ts +++ b/clients/client-wellarchitected/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "wellarchitected.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "wellarchitected.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "wellarchitected.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "wellarchitected.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "wellarchitected.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "wellarchitected", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "wellarchitected.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "wellarchitected.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "wellarchitected.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "wellarchitected.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "wellarchitected.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "wellarchitected", + regionHash, + partitionHash, + }); diff --git a/clients/client-workdocs/endpoints.ts b/clients/client-workdocs/endpoints.ts index a83454f484ae4..0a4e85912a755 100644 --- a/clients/client-workdocs/endpoints.ts +++ b/clients/client-workdocs/endpoints.ts @@ -1,134 +1,68 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "workdocs.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "workdocs.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "workdocs.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "workdocs.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "workdocs.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "workdocs-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-west-2": { + hostname: "workdocs-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "workdocs.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "workdocs.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "workdocs.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "workdocs.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "workdocs-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "workdocs-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "workdocs.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "workdocs.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "workdocs", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "workdocs.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "workdocs.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "workdocs.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "workdocs.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "workdocs.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "workdocs", + regionHash, + partitionHash, + }); diff --git a/clients/client-worklink/endpoints.ts b/clients/client-worklink/endpoints.ts index dc8aa656bd45c..cd8b21e3dff5c 100644 --- a/clients/client-worklink/endpoints.ts +++ b/clients/client-worklink/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "worklink.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "worklink.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "worklink.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "worklink.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "worklink.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "worklink", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "worklink.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "worklink.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "worklink.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "worklink.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "worklink.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "worklink", + regionHash, + partitionHash, + }); diff --git a/clients/client-workmail/endpoints.ts b/clients/client-workmail/endpoints.ts index e42c13c65d2da..b46c3be31362f 100644 --- a/clients/client-workmail/endpoints.ts +++ b/clients/client-workmail/endpoints.ts @@ -1,102 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "workmail.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "workmail.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "workmail.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "workmail.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "workmail.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "eu-west-1": - regionInfo = { - hostname: "workmail.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "workmail.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "workmail.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "workmail", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "workmail.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "workmail.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "workmail.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "workmail.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "workmail.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "workmail", + regionHash, + partitionHash, + }); diff --git a/clients/client-workmailmessageflow/endpoints.ts b/clients/client-workmailmessageflow/endpoints.ts index 3f0d3a9519e27..8ff93c35b521f 100644 --- a/clients/client-workmailmessageflow/endpoints.ts +++ b/clients/client-workmailmessageflow/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "workmailmessageflow.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "workmailmessageflow.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "workmailmessageflow.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "workmailmessageflow.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "workmailmessageflow.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "workmailmessageflow", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "workmailmessageflow.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "workmailmessageflow.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "workmailmessageflow.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "workmailmessageflow.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "workmailmessageflow.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "workmailmessageflow", + regionHash, + partitionHash, + }); diff --git a/clients/client-workspaces/endpoints.ts b/clients/client-workspaces/endpoints.ts index f63f8ad4703aa..bab71aa79f081 100644 --- a/clients/client-workspaces/endpoints.ts +++ b/clients/client-workspaces/endpoints.ts @@ -1,195 +1,72 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "workspaces.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "workspaces.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "workspaces.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "workspaces.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "workspaces.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "workspaces-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-gov-west-1": { + hostname: "workspaces-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-2": { + hostname: "workspaces-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "ap-northeast-1": - regionInfo = { - hostname: "workspaces.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "workspaces.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "workspaces.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "workspaces.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "workspaces.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "workspaces.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "workspaces.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "workspaces.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "workspaces.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "workspaces.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "workspaces-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "workspaces-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "workspaces-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "workspaces.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "workspaces.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "workspaces.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-iso-east-1": - regionInfo = { - hostname: "workspaces.us-iso-east-1.c2s.ic.gov", - partition: "aws-iso", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "workspaces.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "workspaces", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "workspaces.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "workspaces.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "workspaces.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "workspaces.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "workspaces.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "workspaces", + regionHash, + partitionHash, + }); diff --git a/clients/client-xray/endpoints.ts b/clients/client-xray/endpoints.ts index b166a2413afb5..c3ed8a537af24 100644 --- a/clients/client-xray/endpoints.ts +++ b/clients/client-xray/endpoints.ts @@ -1,276 +1,86 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "xray.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "xray.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "xray.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "xray.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "xray.{region}.amazonaws.com"; - -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); +const regionHash: RegionHash = { + "fips-us-east-1": { + hostname: "xray-fips.us-east-1.amazonaws.com", + signingRegion: "us-east-1", + }, + "fips-us-east-2": { + hostname: "xray-fips.us-east-2.amazonaws.com", + signingRegion: "us-east-2", + }, + "fips-us-gov-east-1": { + hostname: "xray-fips.us-gov-east-1.amazonaws.com", + signingRegion: "us-gov-east-1", + }, + "fips-us-gov-west-1": { + hostname: "xray-fips.us-gov-west-1.amazonaws.com", + signingRegion: "us-gov-west-1", + }, + "fips-us-west-1": { + hostname: "xray-fips.us-west-1.amazonaws.com", + signingRegion: "us-west-1", + }, + "fips-us-west-2": { + hostname: "xray-fips.us-west-2.amazonaws.com", + signingRegion: "us-west-2", + }, +}; -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - case "af-south-1": - regionInfo = { - hostname: "xray.af-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-east-1": - regionInfo = { - hostname: "xray.ap-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-1": - regionInfo = { - hostname: "xray.ap-northeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-2": - regionInfo = { - hostname: "xray.ap-northeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ap-northeast-3": - regionInfo = { - hostname: "xray.ap-northeast-3.amazonaws.com", - partition: "aws", - }; - break; - case "ap-south-1": - regionInfo = { - hostname: "xray.ap-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-1": - regionInfo = { - hostname: "xray.ap-southeast-1.amazonaws.com", - partition: "aws", - }; - break; - case "ap-southeast-2": - regionInfo = { - hostname: "xray.ap-southeast-2.amazonaws.com", - partition: "aws", - }; - break; - case "ca-central-1": - regionInfo = { - hostname: "xray.ca-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "cn-north-1": - regionInfo = { - hostname: "xray.cn-north-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "cn-northwest-1": - regionInfo = { - hostname: "xray.cn-northwest-1.amazonaws.com.cn", - partition: "aws-cn", - }; - break; - case "eu-central-1": - regionInfo = { - hostname: "xray.eu-central-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-north-1": - regionInfo = { - hostname: "xray.eu-north-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-south-1": - regionInfo = { - hostname: "xray.eu-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-1": - regionInfo = { - hostname: "xray.eu-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-2": - regionInfo = { - hostname: "xray.eu-west-2.amazonaws.com", - partition: "aws", - }; - break; - case "eu-west-3": - regionInfo = { - hostname: "xray.eu-west-3.amazonaws.com", - partition: "aws", - }; - break; - case "fips-us-east-1": - regionInfo = { - hostname: "xray-fips.us-east-1.amazonaws.com", - partition: "aws", - signingRegion: "us-east-1", - }; - break; - case "fips-us-east-2": - regionInfo = { - hostname: "xray-fips.us-east-2.amazonaws.com", - partition: "aws", - signingRegion: "us-east-2", - }; - break; - case "fips-us-gov-east-1": - regionInfo = { - hostname: "xray-fips.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-east-1", - }; - break; - case "fips-us-gov-west-1": - regionInfo = { - hostname: "xray-fips.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - signingRegion: "us-gov-west-1", - }; - break; - case "fips-us-west-1": - regionInfo = { - hostname: "xray-fips.us-west-1.amazonaws.com", - partition: "aws", - signingRegion: "us-west-1", - }; - break; - case "fips-us-west-2": - regionInfo = { - hostname: "xray-fips.us-west-2.amazonaws.com", - partition: "aws", - signingRegion: "us-west-2", - }; - break; - case "me-south-1": - regionInfo = { - hostname: "xray.me-south-1.amazonaws.com", - partition: "aws", - }; - break; - case "sa-east-1": - regionInfo = { - hostname: "xray.sa-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-1": - regionInfo = { - hostname: "xray.us-east-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-east-2": - regionInfo = { - hostname: "xray.us-east-2.amazonaws.com", - partition: "aws", - }; - break; - case "us-gov-east-1": - regionInfo = { - hostname: "xray.us-gov-east-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-gov-west-1": - regionInfo = { - hostname: "xray.us-gov-west-1.amazonaws.com", - partition: "aws-us-gov", - }; - break; - case "us-west-1": - regionInfo = { - hostname: "xray.us-west-1.amazonaws.com", - partition: "aws", - }; - break; - case "us-west-2": - regionInfo = { - hostname: "xray.us-west-2.amazonaws.com", - partition: "aws", - }; - break; - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "xray", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "fips-us-east-1", + "fips-us-east-2", + "fips-us-west-1", + "fips-us-west-2", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "xray.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "xray.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "xray.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "xray.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["fips-us-gov-east-1", "fips-us-gov-west-1", "us-gov-east-1", "us-gov-west-1"], + hostname: "xray.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "xray", + regionHash, + partitionHash, + }); diff --git a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/EndpointGenerator.java b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/EndpointGenerator.java index 9f8084aeaa106..b8792f588fd2d 100644 --- a/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/EndpointGenerator.java +++ b/codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/EndpointGenerator.java @@ -20,6 +20,7 @@ import java.util.Optional; import java.util.Set; import java.util.TreeMap; +import java.util.TreeSet; import software.amazon.smithy.aws.traits.ServiceTrait; import software.amazon.smithy.aws.traits.auth.SigV4Trait; import software.amazon.smithy.codegen.core.CodegenException; @@ -29,11 +30,9 @@ import software.amazon.smithy.model.shapes.ServiceShape; import software.amazon.smithy.typescript.codegen.TypeScriptDependency; import software.amazon.smithy.typescript.codegen.TypeScriptWriter; -import software.amazon.smithy.utils.CaseUtils; import software.amazon.smithy.utils.IoUtils; import software.amazon.smithy.utils.OptionalUtils; import software.amazon.smithy.utils.SmithyInternalApi; -import software.amazon.smithy.utils.StringUtils; /** * Writes out a file that resolves endpoints using endpoints.json, but the @@ -48,17 +47,16 @@ final class EndpointGenerator implements Runnable { private final ObjectNode endpointData; private final ServiceTrait serviceTrait; private final String endpointPrefix; - private final String baseSigningSerivce; + private final String baseSigningService; private final Map partitions = new TreeMap<>(); private final Map endpoints = new TreeMap<>(); - private final Map regionPartitionsMap = new TreeMap<>(); EndpointGenerator(ServiceShape service, TypeScriptWriter writer) { this.writer = writer; serviceTrait = service.getTrait(ServiceTrait.class) .orElseThrow(() -> new CodegenException("No service trait found on " + service.getId())); endpointPrefix = serviceTrait.getEndpointPrefix(); - baseSigningSerivce = service.getTrait(SigV4Trait.class).map(SigV4Trait::getName) + baseSigningService = service.getTrait(SigV4Trait.class).map(SigV4Trait::getName) .orElse(serviceTrait.getArnNamespace()); endpointData = Node.parse(IoUtils.readUtf8Resource(getClass(), "endpoints.json")).expectObjectNode(); validateVersion(); @@ -91,42 +89,51 @@ private void loadServiceEndpoints() { ObjectNode endpointMap = serviceData.getObjectMember("endpoints").orElse(Node.objectNode()); for (Map.Entry entry : endpointMap.getStringMap().entrySet()) { - // Merge the endpoint settings into the resolved service settings. - ObjectNode config = partition.getDefaults().merge(entry.getValue().expectObjectNode()); - // Resolve the hostname. - String hostName = config.expectStringMember("hostname").getValue(); - hostName = hostName.replace("{dnsSuffix}", dnsSuffix); - hostName = hostName.replace("{service}", endpointPrefix); - hostName = hostName.replace("{region}", entry.getKey()); - config = config.withMember("hostname", hostName); - endpoints.put(entry.getKey(), config); - regionPartitionsMap.put(entry.getKey(), partition); + ObjectNode config = entry.getValue().expectObjectNode(); + if (config.containsMember("hostname")) { + // Resolve the hostname. + String hostName = config.expectStringMember("hostname").getValue(); + hostName = hostName.replace("{dnsSuffix}", dnsSuffix); + hostName = hostName.replace("{service}", endpointPrefix); + hostName = hostName.replace("{region}", entry.getKey()); + config = config.withMember("hostname", hostName); + endpoints.put(entry.getKey(), config); + } } } } @Override public void run() { - writePartitionTemplates(); - writePartitionRegions(); + writeRegionHash(); + writePartitionHash(); writeEndpointProviderFunction(); } - private void writePartitionTemplates() { - writer.write("// Partition default templates"); - partitions.values().forEach(partition -> { - writer.write("const $L = $S;", partition.templateVariableName, partition.templateValue); + private void writeRegionHash() { + writer.addImport("RegionHash", "RegionHash", TypeScriptDependency.CONFIG_RESOLVER.packageName); + writer.openBlock("const regionHash: RegionHash = {", "};", () -> { + for (Map.Entry entry : endpoints.entrySet()) { + writeEndpointSpecificResolver(entry.getKey(), entry.getValue()); + } }); writer.write(""); } - private void writePartitionRegions() { - writer.write("// Partition regions"); - partitions.values().forEach(partition -> { - writer.openBlock("const $L = new Set([", "]);", partition.regionVariableName, () -> { - for (String region : partition.getAllRegions()) { - writer.write("$S,", region); - } + private void writePartitionHash() { + writer.addImport("PartitionHash", "PartitionHash", TypeScriptDependency.CONFIG_RESOLVER.packageName); + writer.openBlock("const partitionHash: PartitionHash = {", "};", () -> { + partitions.values().forEach(partition -> { + writer.openBlock("$S: {", "},", partition.identifier, () -> { + writer.openBlock("regions: [", "],", () -> { + for (String region : partition.getAllRegions()) { + writer.write("$S,", region); + } + }); + OptionalUtils.ifPresentOrElse(partition.getPartitionEndpoint(), + endpoint -> writer.write("endpoint: $S,", endpoint), + () -> writer.write("hostname: $S,", partition.hostnameTemplate)); + }); }); }); writer.write(""); @@ -134,77 +141,40 @@ private void writePartitionRegions() { private void writeEndpointProviderFunction() { writer.addImport("RegionInfoProvider", "RegionInfoProvider", TypeScriptDependency.AWS_SDK_TYPES.packageName); - writer.addImport("RegionInfo", "RegionInfo", TypeScriptDependency.AWS_SDK_TYPES.packageName); - writer.openBlock("export const defaultRegionInfoProvider: RegionInfoProvider = (\n" + writer.addImport("getRegionInfo", "getRegionInfo", TypeScriptDependency.CONFIG_RESOLVER.packageName); + writer.openBlock("export const defaultRegionInfoProvider: RegionInfoProvider = async (\n" + " region: string,\n" + " options?: any\n" - + ") => {", "};", () -> { - writer.write("let regionInfo: RegionInfo | undefined = undefined;"); - writer.openBlock("switch (region) {", "}", () -> { - writer.write("// First, try to match exact region names."); - for (Map.Entry entry : endpoints.entrySet()) { - writer.write("case $S:", entry.getKey()).indent(); - writeEndpointSpecificResolver(entry.getKey(), entry.getValue()); - writer.write("break;"); - writer.dedent(); - } - writer.write("// Next, try to match partition endpoints."); - writer.write("default:").indent(); - partitions.values().forEach(partition -> { - writer.openBlock("if ($L.has(region)) {", "}", partition.regionVariableName, () -> { - writePartitionEndpointResolver(partition); }); - }); - // Default to using the AWS partition resolver. - writer.write("// Finally, assume it's an AWS partition endpoint."); - writer.openBlock("if (regionInfo === undefined) {", "}", () -> { - writePartitionEndpointResolver(partitions.get("aws")); }); - writer.dedent(); + + ") => ", ";", () -> { + writer.openBlock("getRegionInfo(region, {", "})", () -> { + writer.write("...options,"); + writer.write("signingService: $S,", baseSigningService); + writer.write("regionHash,"); + writer.write("partitionHash,"); }); - writer.write("return Promise.resolve({ signingService: $S, ...regionInfo });", baseSigningSerivce); }); } - private void writePartitionEndpointResolver(Partition partition) { - OptionalUtils.ifPresentOrElse( - partition.getPartitionEndpoint(), - name -> writer.write("return defaultRegionInfoProvider($S);", name), - () -> { - writer.openBlock("regionInfo = {", "};", () -> { - String template = partition.templateVariableName; - writer.write("hostname: $L.replace(\"{region}\", region),", template); - writer.write("partition: $S,", partition.identifier); - writeAdditionalEndpointSettings(partition.getDefaults()); - }); - } - ); - } - private void writeEndpointSpecificResolver(String region, ObjectNode resolved) { - String hostname = resolved.expectStringMember("hostname").getValue(); - writer.openBlock("regionInfo = {", "};", () -> { - writer.write("hostname: $S,", hostname); - writer.write("partition: $S,", regionPartitionsMap.get(region).identifier); - writeAdditionalEndpointSettings(resolved); - }); - } - - // Write credential scope settings into the resolved endpoint object. - private void writeAdditionalEndpointSettings(ObjectNode settings) { - settings.getObjectMember("credentialScope").ifPresent(scope -> { - scope.getStringMember("region").ifPresent(signingRegion -> { - writer.write("signingRegion: $S,", signingRegion); - }); - scope.getStringMember("service").ifPresent(signingService -> { - writer.write("signingService: $S,", signingService); + if (resolved.containsMember("hostname") || resolved.containsMember("credentialScope")) { + writer.openBlock("$S: {", "},", region, () -> { + String hostname = resolved.expectStringMember("hostname").getValue(); + writer.write("hostname: $S,", hostname); + resolved.getObjectMember("credentialScope").ifPresent(scope -> { + scope.getStringMember("region").ifPresent(signingRegion -> { + writer.write("signingRegion: $S,", signingRegion); + }); + scope.getStringMember("service").ifPresent(signingService -> { + writer.write("signingService: $S,", signingService); + }); + }); }); - }); + } } private final class Partition { final ObjectNode defaults; - final String regionVariableName; - final String templateVariableName; - final String templateValue; + final String hostnameTemplate; final String dnsSuffix; final String identifier; private final ObjectNode config; @@ -219,12 +189,7 @@ private Partition(ObjectNode config, String partition) { String template = defaults.expectStringMember("hostname").getValue(); template = template.replace("{service}", endpointPrefix); template = template.replace("{dnsSuffix}", config.expectStringMember("dnsSuffix").getValue()); - templateValue = template; - - // Compute the template and regions variable names. - String snakePartition = StringUtils.upperCase(CaseUtils.toSnakeCase(partition)); - templateVariableName = snakePartition + "_TEMPLATE"; - regionVariableName = snakePartition + "_REGIONS"; + hostnameTemplate = template; dnsSuffix = config.expectStringMember("dnsSuffix").getValue(); identifier = partition; @@ -240,7 +205,16 @@ ObjectNode getService() { } Set getAllRegions() { - return config.getObjectMember("regions").orElse(Node.objectNode()).getStringMap().keySet(); + Set regions = new TreeSet(); + regions.addAll( + config.getObjectMember("regions") + .orElse(Node.objectNode()).getStringMap().keySet() + ); + regions.addAll( + getService().getObjectMember("endpoints") + .orElse(Node.objectNode()).getStringMap().keySet() + ); + return regions; } Optional getPartitionEndpoint() { diff --git a/protocol_tests/aws-ec2/endpoints.ts b/protocol_tests/aws-ec2/endpoints.ts index 73295c30be682..2bcdf2084d962 100644 --- a/protocol_tests/aws-ec2/endpoints.ts +++ b/protocol_tests/aws-ec2/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "awsec2.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "awsec2.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "awsec2.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "awsec2.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "awsec2.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "awsec2", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "awsec2.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "awsec2.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "awsec2.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "awsec2.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "awsec2.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "awsec2", + regionHash, + partitionHash, + }); diff --git a/protocol_tests/aws-json-10/endpoints.ts b/protocol_tests/aws-json-10/endpoints.ts index 7e5592d24db16..fd2430f96ac9a 100644 --- a/protocol_tests/aws-json-10/endpoints.ts +++ b/protocol_tests/aws-json-10/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "jsonrpc10.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "jsonrpc10.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "jsonrpc10.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "jsonrpc10.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "jsonrpc10.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "jsonrpc10", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "jsonrpc10.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "jsonrpc10.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "jsonrpc10.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "jsonrpc10.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "jsonrpc10.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "jsonrpc10", + regionHash, + partitionHash, + }); diff --git a/protocol_tests/aws-json/endpoints.ts b/protocol_tests/aws-json/endpoints.ts index ccc8f8ab7941c..5d3e824b8e15e 100644 --- a/protocol_tests/aws-json/endpoints.ts +++ b/protocol_tests/aws-json/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "jsonprotocol.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "jsonprotocol.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "jsonprotocol.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "jsonprotocol.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "jsonprotocol.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "foo", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "jsonprotocol.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "jsonprotocol.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "jsonprotocol.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "jsonprotocol.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "jsonprotocol.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "foo", + regionHash, + partitionHash, + }); diff --git a/protocol_tests/aws-query/endpoints.ts b/protocol_tests/aws-query/endpoints.ts index 5447a8038ff66..68d15b8050590 100644 --- a/protocol_tests/aws-query/endpoints.ts +++ b/protocol_tests/aws-query/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "awsquery.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "awsquery.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "awsquery.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "awsquery.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "awsquery.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "awsquery", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "awsquery.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "awsquery.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "awsquery.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "awsquery.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "awsquery.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "awsquery", + regionHash, + partitionHash, + }); diff --git a/protocol_tests/aws-restjson/endpoints.ts b/protocol_tests/aws-restjson/endpoints.ts index 0f084bbf0de87..7f1b98360736e 100644 --- a/protocol_tests/aws-restjson/endpoints.ts +++ b/protocol_tests/aws-restjson/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "restjson.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "restjson.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "restjson.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "restjson.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "restjson.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "restjson", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "restjson.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "restjson.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "restjson.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "restjson.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "restjson.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "restjson", + regionHash, + partitionHash, + }); diff --git a/protocol_tests/aws-restxml/endpoints.ts b/protocol_tests/aws-restxml/endpoints.ts index d795c2120664c..42cfe0c66f254 100644 --- a/protocol_tests/aws-restxml/endpoints.ts +++ b/protocol_tests/aws-restxml/endpoints.ts @@ -1,84 +1,57 @@ -import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types"; +import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver"; +import { RegionInfoProvider } from "@aws-sdk/types"; -// Partition default templates -const AWS_TEMPLATE = "restxml.{region}.amazonaws.com"; -const AWS_CN_TEMPLATE = "restxml.{region}.amazonaws.com.cn"; -const AWS_ISO_TEMPLATE = "restxml.{region}.c2s.ic.gov"; -const AWS_ISO_B_TEMPLATE = "restxml.{region}.sc2s.sgov.gov"; -const AWS_US_GOV_TEMPLATE = "restxml.{region}.amazonaws.com"; +const regionHash: RegionHash = {}; -// Partition regions -const AWS_REGIONS = new Set([ - "af-south-1", - "ap-east-1", - "ap-northeast-1", - "ap-northeast-2", - "ap-northeast-3", - "ap-south-1", - "ap-southeast-1", - "ap-southeast-2", - "ca-central-1", - "eu-central-1", - "eu-north-1", - "eu-south-1", - "eu-west-1", - "eu-west-2", - "eu-west-3", - "me-south-1", - "sa-east-1", - "us-east-1", - "us-east-2", - "us-west-1", - "us-west-2", -]); -const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]); -const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]); -const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]); -const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]); - -export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => { - let regionInfo: RegionInfo | undefined = undefined; - switch (region) { - // First, try to match exact region names. - // Next, try to match partition endpoints. - default: - if (AWS_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - if (AWS_CN_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_CN_TEMPLATE.replace("{region}", region), - partition: "aws-cn", - }; - } - if (AWS_ISO_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_TEMPLATE.replace("{region}", region), - partition: "aws-iso", - }; - } - if (AWS_ISO_B_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region), - partition: "aws-iso-b", - }; - } - if (AWS_US_GOV_REGIONS.has(region)) { - regionInfo = { - hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region), - partition: "aws-us-gov", - }; - } - // Finally, assume it's an AWS partition endpoint. - if (regionInfo === undefined) { - regionInfo = { - hostname: AWS_TEMPLATE.replace("{region}", region), - partition: "aws", - }; - } - } - return Promise.resolve({ signingService: "restxml", ...regionInfo }); +const partitionHash: PartitionHash = { + aws: { + regions: [ + "af-south-1", + "ap-east-1", + "ap-northeast-1", + "ap-northeast-2", + "ap-northeast-3", + "ap-south-1", + "ap-southeast-1", + "ap-southeast-2", + "ca-central-1", + "eu-central-1", + "eu-north-1", + "eu-south-1", + "eu-west-1", + "eu-west-2", + "eu-west-3", + "me-south-1", + "sa-east-1", + "us-east-1", + "us-east-2", + "us-west-1", + "us-west-2", + ], + hostname: "restxml.{region}.amazonaws.com", + }, + "aws-cn": { + regions: ["cn-north-1", "cn-northwest-1"], + hostname: "restxml.{region}.amazonaws.com.cn", + }, + "aws-iso": { + regions: ["us-iso-east-1"], + hostname: "restxml.{region}.c2s.ic.gov", + }, + "aws-iso-b": { + regions: ["us-isob-east-1"], + hostname: "restxml.{region}.sc2s.sgov.gov", + }, + "aws-us-gov": { + regions: ["us-gov-east-1", "us-gov-west-1"], + hostname: "restxml.{region}.amazonaws.com", + }, }; + +export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) => + getRegionInfo(region, { + ...options, + signingService: "restxml", + regionHash, + partitionHash, + });