Skip to content

Commit

Permalink
fix: update clients with correct endpoint prefix (#720)
Browse files Browse the repository at this point in the history
* feat: infer endpoint prefix from a map file

* fix: update copy script to override endpoints.ts

* chore: add endpoint functional test cases

* fix: update clients with correct endpoint prefix from C2J
  • Loading branch information
AllanZhengYP authored Jan 13, 2020
1 parent 396a065 commit 5356dbb
Show file tree
Hide file tree
Showing 39 changed files with 1,885 additions and 477 deletions.
79 changes: 71 additions & 8 deletions clients/client-appstream/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types";

// Partition default templates
const AWS_TEMPLATE = "appstream.{region}.amazonaws.com";
const AWS_CN_TEMPLATE = "appstream.{region}.amazonaws.com.cn";
const AWS_ISO_TEMPLATE = "appstream.{region}.c2s.ic.gov";
const AWS_ISO_B_TEMPLATE = "appstream.{region}.sc2s.sgov.gov";
const AWS_US_GOV_TEMPLATE = "appstream.{region}.amazonaws.com";
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([
Expand Down Expand Up @@ -40,11 +40,72 @@ export const defaultRegionInfoProvider: RegionInfoProvider = (
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",
signingService: "appstream"
};
break;
case "ap-northeast-2":
regionInfo = {
hostname: "appstream2.ap-northeast-2.amazonaws.com",
signingService: "appstream"
};
break;
case "ap-southeast-1":
regionInfo = {
hostname: "appstream2.ap-southeast-1.amazonaws.com",
signingService: "appstream"
};
break;
case "ap-southeast-2":
regionInfo = {
hostname: "appstream2.ap-southeast-2.amazonaws.com",
signingService: "appstream"
};
break;
case "eu-central-1":
regionInfo = {
hostname: "appstream2.eu-central-1.amazonaws.com",
signingService: "appstream"
};
break;
case "eu-west-1":
regionInfo = {
hostname: "appstream2.eu-west-1.amazonaws.com",
signingService: "appstream"
};
break;
case "fips":
regionInfo = {
hostname: "appstream2-fips.us-gov-west-1.amazonaws.com",
signingRegion: "us-gov-west-1"
};
break;
case "us-east-1":
regionInfo = {
hostname: "appstream2.us-east-1.amazonaws.com",
signingService: "appstream"
};
break;
case "us-gov-west-1":
regionInfo = {
hostname: "appstream2.us-gov-west-1.amazonaws.com",
signingService: "appstream"
};
break;
case "us-west-2":
regionInfo = {
hostname: "appstream2.us-west-2.amazonaws.com",
signingService: "appstream"
};
break;
// Next, try to match partition endpoints.
default:
if (AWS_REGIONS.has(region)) {
regionInfo = {
hostname: AWS_TEMPLATE.replace("{region}", region)
hostname: AWS_TEMPLATE.replace("{region}", region),
signingService: "appstream"
};
}
if (AWS_CN_REGIONS.has(region)) {
Expand All @@ -64,13 +125,15 @@ export const defaultRegionInfoProvider: RegionInfoProvider = (
}
if (AWS_US_GOV_REGIONS.has(region)) {
regionInfo = {
hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region)
hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region),
signingService: "appstream"
};
}
// Finally, assume it's an AWS partition endpoint.
if (regionInfo === undefined) {
regionInfo = {
hostname: AWS_TEMPLATE.replace("{region}", region)
hostname: AWS_TEMPLATE.replace("{region}", region),
signingService: "appstream"
};
}
}
Expand Down
106 changes: 87 additions & 19 deletions clients/client-cloudhsm-v2/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { RegionInfo, 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 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";

// Partition regions
const AWS_REGIONS = new Set([
Expand Down Expand Up @@ -40,66 +40,132 @@ export const defaultRegionInfoProvider: RegionInfoProvider = (
let regionInfo: RegionInfo | undefined = undefined;
switch (region) {
// First, try to match exact region names.
case "ap-east-1":
regionInfo = {
hostname: "cloudhsmv2.ap-east-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "ap-northeast-1":
regionInfo = {
hostname: "cloudhsm.ap-northeast-1.amazonaws.com"
hostname: "cloudhsmv2.ap-northeast-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "ap-northeast-2":
regionInfo = {
hostname: "cloudhsmv2.ap-northeast-2.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "ap-south-1":
regionInfo = {
hostname: "cloudhsmv2.ap-south-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "ap-southeast-1":
regionInfo = {
hostname: "cloudhsm.ap-southeast-1.amazonaws.com"
hostname: "cloudhsmv2.ap-southeast-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "ap-southeast-2":
regionInfo = {
hostname: "cloudhsm.ap-southeast-2.amazonaws.com"
hostname: "cloudhsmv2.ap-southeast-2.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "ca-central-1":
regionInfo = {
hostname: "cloudhsm.ca-central-1.amazonaws.com"
hostname: "cloudhsmv2.ca-central-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "eu-central-1":
regionInfo = {
hostname: "cloudhsm.eu-central-1.amazonaws.com"
hostname: "cloudhsmv2.eu-central-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "eu-north-1":
regionInfo = {
hostname: "cloudhsmv2.eu-north-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "eu-west-1":
regionInfo = {
hostname: "cloudhsm.eu-west-1.amazonaws.com"
hostname: "cloudhsmv2.eu-west-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "eu-west-2":
regionInfo = {
hostname: "cloudhsmv2.eu-west-2.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "eu-west-3":
regionInfo = {
hostname: "cloudhsmv2.eu-west-3.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "me-south-1":
regionInfo = {
hostname: "cloudhsmv2.me-south-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "sa-east-1":
regionInfo = {
hostname: "cloudhsmv2.sa-east-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "us-east-1":
regionInfo = {
hostname: "cloudhsm.us-east-1.amazonaws.com"
hostname: "cloudhsmv2.us-east-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "us-east-2":
regionInfo = {
hostname: "cloudhsm.us-east-2.amazonaws.com"
hostname: "cloudhsmv2.us-east-2.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "us-gov-east-1":
regionInfo = {
hostname: "cloudhsmv2.us-gov-east-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "us-gov-west-1":
regionInfo = {
hostname: "cloudhsm.us-gov-west-1.amazonaws.com"
hostname: "cloudhsmv2.us-gov-west-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "us-west-1":
regionInfo = {
hostname: "cloudhsm.us-west-1.amazonaws.com"
hostname: "cloudhsmv2.us-west-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "us-west-2":
regionInfo = {
hostname: "cloudhsm.us-west-2.amazonaws.com"
hostname: "cloudhsmv2.us-west-2.amazonaws.com",
signingService: "cloudhsm"
};
break;
// Next, try to match partition endpoints.
default:
if (AWS_REGIONS.has(region)) {
regionInfo = {
hostname: AWS_TEMPLATE.replace("{region}", region)
hostname: AWS_TEMPLATE.replace("{region}", region),
signingService: "cloudhsm"
};
}
if (AWS_CN_REGIONS.has(region)) {
Expand All @@ -119,13 +185,15 @@ export const defaultRegionInfoProvider: RegionInfoProvider = (
}
if (AWS_US_GOV_REGIONS.has(region)) {
regionInfo = {
hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region)
hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region),
signingService: "cloudhsm"
};
}
// Finally, assume it's an AWS partition endpoint.
if (regionInfo === undefined) {
regionInfo = {
hostname: AWS_TEMPLATE.replace("{region}", region)
hostname: AWS_TEMPLATE.replace("{region}", region),
signingService: "cloudhsm"
};
}
}
Expand Down
60 changes: 5 additions & 55 deletions clients/client-cloudsearch-domain/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { RegionInfo, 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 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";

// Partition regions
const AWS_REGIONS = new Set([
Expand Down Expand Up @@ -40,56 +40,6 @@ export const defaultRegionInfoProvider: RegionInfoProvider = (
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"
};
break;
case "ap-northeast-2":
regionInfo = {
hostname: "cloudsearch.ap-northeast-2.amazonaws.com"
};
break;
case "ap-southeast-1":
regionInfo = {
hostname: "cloudsearch.ap-southeast-1.amazonaws.com"
};
break;
case "ap-southeast-2":
regionInfo = {
hostname: "cloudsearch.ap-southeast-2.amazonaws.com"
};
break;
case "eu-central-1":
regionInfo = {
hostname: "cloudsearch.eu-central-1.amazonaws.com"
};
break;
case "eu-west-1":
regionInfo = {
hostname: "cloudsearch.eu-west-1.amazonaws.com"
};
break;
case "sa-east-1":
regionInfo = {
hostname: "cloudsearch.sa-east-1.amazonaws.com"
};
break;
case "us-east-1":
regionInfo = {
hostname: "cloudsearch.us-east-1.amazonaws.com"
};
break;
case "us-west-1":
regionInfo = {
hostname: "cloudsearch.us-west-1.amazonaws.com"
};
break;
case "us-west-2":
regionInfo = {
hostname: "cloudsearch.us-west-2.amazonaws.com"
};
break;
// Next, try to match partition endpoints.
default:
if (AWS_REGIONS.has(region)) {
Expand Down
10 changes: 5 additions & 5 deletions clients/client-connectparticipant/endpoints.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { RegionInfo, 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 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";

// Partition regions
const AWS_REGIONS = new Set([
Expand Down
Loading

0 comments on commit 5356dbb

Please sign in to comment.