-
Notifications
You must be signed in to change notification settings - Fork 545
/
endpoints.ts
201 lines (198 loc) · 5.45 KB
/
endpoints.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
import { RegionInfo, 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";
// Partition regions
const AWS_REGIONS = new Set([
"ap-south-1",
"eu-north-1",
"eu-west-3",
"eu-west-2",
"eu-west-1",
"ap-northeast-2",
"ap-northeast-1",
"me-south-1",
"ca-central-1",
"sa-east-1",
"ap-east-1",
"ap-southeast-1",
"ap-southeast-2",
"eu-central-1",
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2"
]);
const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]);
const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]);
const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]);
const AWS_US_GOV_REGIONS = new Set(["us-gov-west-1", "us-gov-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 "ap-east-1":
regionInfo = {
hostname: "cloudhsmv2.ap-east-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "ap-northeast-1":
regionInfo = {
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: "cloudhsmv2.ap-southeast-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "ap-southeast-2":
regionInfo = {
hostname: "cloudhsmv2.ap-southeast-2.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "ca-central-1":
regionInfo = {
hostname: "cloudhsmv2.ca-central-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "eu-central-1":
regionInfo = {
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: "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: "cloudhsmv2.us-east-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "us-east-2":
regionInfo = {
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: "cloudhsmv2.us-gov-west-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "us-west-1":
regionInfo = {
hostname: "cloudhsmv2.us-west-1.amazonaws.com",
signingService: "cloudhsm"
};
break;
case "us-west-2":
regionInfo = {
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),
signingService: "cloudhsm"
};
}
if (AWS_CN_REGIONS.has(region)) {
regionInfo = {
hostname: AWS_CN_TEMPLATE.replace("{region}", region)
};
}
if (AWS_ISO_REGIONS.has(region)) {
regionInfo = {
hostname: AWS_ISO_TEMPLATE.replace("{region}", region)
};
}
if (AWS_ISO_B_REGIONS.has(region)) {
regionInfo = {
hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region)
};
}
if (AWS_US_GOV_REGIONS.has(region)) {
regionInfo = {
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),
signingService: "cloudhsm"
};
}
}
return Promise.resolve(regionInfo);
};