Skip to content

Commit 88de69b

Browse files
authored
feat(clients): modular endpoints resolution (#2704)
1 parent c182081 commit 88de69b

File tree

283 files changed

+19225
-48054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+19225
-48054
lines changed

Diff for: clients/client-accessanalyzer/endpoints.ts

+88-268
Original file line numberDiff line numberDiff line change
@@ -1,271 +1,91 @@
1-
import { RegionInfo, RegionInfoProvider } from "@aws-sdk/types";
1+
import { PartitionHash, RegionHash, getRegionInfo } from "@aws-sdk/config-resolver";
2+
import { RegionInfoProvider } from "@aws-sdk/types";
23

3-
// Partition default templates
4-
const AWS_TEMPLATE = "access-analyzer.{region}.amazonaws.com";
5-
const AWS_CN_TEMPLATE = "access-analyzer.{region}.amazonaws.com.cn";
6-
const AWS_ISO_TEMPLATE = "access-analyzer.{region}.c2s.ic.gov";
7-
const AWS_ISO_B_TEMPLATE = "access-analyzer.{region}.sc2s.sgov.gov";
8-
const AWS_US_GOV_TEMPLATE = "access-analyzer.{region}.amazonaws.com";
9-
10-
// Partition regions
11-
const AWS_REGIONS = new Set([
12-
"af-south-1",
13-
"ap-east-1",
14-
"ap-northeast-1",
15-
"ap-northeast-2",
16-
"ap-northeast-3",
17-
"ap-south-1",
18-
"ap-southeast-1",
19-
"ap-southeast-2",
20-
"ca-central-1",
21-
"eu-central-1",
22-
"eu-north-1",
23-
"eu-south-1",
24-
"eu-west-1",
25-
"eu-west-2",
26-
"eu-west-3",
27-
"me-south-1",
28-
"sa-east-1",
29-
"us-east-1",
30-
"us-east-2",
31-
"us-west-1",
32-
"us-west-2",
33-
]);
34-
const AWS_CN_REGIONS = new Set(["cn-north-1", "cn-northwest-1"]);
35-
const AWS_ISO_REGIONS = new Set(["us-iso-east-1"]);
36-
const AWS_ISO_B_REGIONS = new Set(["us-isob-east-1"]);
37-
const AWS_US_GOV_REGIONS = new Set(["us-gov-east-1", "us-gov-west-1"]);
4+
const regionHash: RegionHash = {
5+
"fips-ca-central-1": {
6+
hostname: "access-analyzer-fips.ca-central-1.amazonaws.com",
7+
signingRegion: "ca-central-1",
8+
},
9+
"fips-us-east-1": {
10+
hostname: "access-analyzer-fips.us-east-1.amazonaws.com",
11+
signingRegion: "us-east-1",
12+
},
13+
"fips-us-east-2": {
14+
hostname: "access-analyzer-fips.us-east-2.amazonaws.com",
15+
signingRegion: "us-east-2",
16+
},
17+
"fips-us-west-1": {
18+
hostname: "access-analyzer-fips.us-west-1.amazonaws.com",
19+
signingRegion: "us-west-1",
20+
},
21+
"fips-us-west-2": {
22+
hostname: "access-analyzer-fips.us-west-2.amazonaws.com",
23+
signingRegion: "us-west-2",
24+
},
25+
"us-gov-east-1": {
26+
hostname: "access-analyzer.us-gov-east-1.amazonaws.com",
27+
signingRegion: "us-gov-east-1",
28+
},
29+
"us-gov-west-1": {
30+
hostname: "access-analyzer.us-gov-west-1.amazonaws.com",
31+
signingRegion: "us-gov-west-1",
32+
},
33+
};
3834

39-
export const defaultRegionInfoProvider: RegionInfoProvider = (region: string, options?: any) => {
40-
let regionInfo: RegionInfo | undefined = undefined;
41-
switch (region) {
42-
// First, try to match exact region names.
43-
case "af-south-1":
44-
regionInfo = {
45-
hostname: "access-analyzer.af-south-1.amazonaws.com",
46-
partition: "aws",
47-
};
48-
break;
49-
case "ap-east-1":
50-
regionInfo = {
51-
hostname: "access-analyzer.ap-east-1.amazonaws.com",
52-
partition: "aws",
53-
};
54-
break;
55-
case "ap-northeast-1":
56-
regionInfo = {
57-
hostname: "access-analyzer.ap-northeast-1.amazonaws.com",
58-
partition: "aws",
59-
};
60-
break;
61-
case "ap-northeast-2":
62-
regionInfo = {
63-
hostname: "access-analyzer.ap-northeast-2.amazonaws.com",
64-
partition: "aws",
65-
};
66-
break;
67-
case "ap-northeast-3":
68-
regionInfo = {
69-
hostname: "access-analyzer.ap-northeast-3.amazonaws.com",
70-
partition: "aws",
71-
};
72-
break;
73-
case "ap-south-1":
74-
regionInfo = {
75-
hostname: "access-analyzer.ap-south-1.amazonaws.com",
76-
partition: "aws",
77-
};
78-
break;
79-
case "ap-southeast-1":
80-
regionInfo = {
81-
hostname: "access-analyzer.ap-southeast-1.amazonaws.com",
82-
partition: "aws",
83-
};
84-
break;
85-
case "ap-southeast-2":
86-
regionInfo = {
87-
hostname: "access-analyzer.ap-southeast-2.amazonaws.com",
88-
partition: "aws",
89-
};
90-
break;
91-
case "ca-central-1":
92-
regionInfo = {
93-
hostname: "access-analyzer.ca-central-1.amazonaws.com",
94-
partition: "aws",
95-
};
96-
break;
97-
case "cn-north-1":
98-
regionInfo = {
99-
hostname: "access-analyzer.cn-north-1.amazonaws.com.cn",
100-
partition: "aws-cn",
101-
};
102-
break;
103-
case "cn-northwest-1":
104-
regionInfo = {
105-
hostname: "access-analyzer.cn-northwest-1.amazonaws.com.cn",
106-
partition: "aws-cn",
107-
};
108-
break;
109-
case "eu-central-1":
110-
regionInfo = {
111-
hostname: "access-analyzer.eu-central-1.amazonaws.com",
112-
partition: "aws",
113-
};
114-
break;
115-
case "eu-north-1":
116-
regionInfo = {
117-
hostname: "access-analyzer.eu-north-1.amazonaws.com",
118-
partition: "aws",
119-
};
120-
break;
121-
case "eu-south-1":
122-
regionInfo = {
123-
hostname: "access-analyzer.eu-south-1.amazonaws.com",
124-
partition: "aws",
125-
};
126-
break;
127-
case "eu-west-1":
128-
regionInfo = {
129-
hostname: "access-analyzer.eu-west-1.amazonaws.com",
130-
partition: "aws",
131-
};
132-
break;
133-
case "eu-west-2":
134-
regionInfo = {
135-
hostname: "access-analyzer.eu-west-2.amazonaws.com",
136-
partition: "aws",
137-
};
138-
break;
139-
case "eu-west-3":
140-
regionInfo = {
141-
hostname: "access-analyzer.eu-west-3.amazonaws.com",
142-
partition: "aws",
143-
};
144-
break;
145-
case "fips-ca-central-1":
146-
regionInfo = {
147-
hostname: "access-analyzer-fips.ca-central-1.amazonaws.com",
148-
partition: "aws",
149-
signingRegion: "ca-central-1",
150-
};
151-
break;
152-
case "fips-us-east-1":
153-
regionInfo = {
154-
hostname: "access-analyzer-fips.us-east-1.amazonaws.com",
155-
partition: "aws",
156-
signingRegion: "us-east-1",
157-
};
158-
break;
159-
case "fips-us-east-2":
160-
regionInfo = {
161-
hostname: "access-analyzer-fips.us-east-2.amazonaws.com",
162-
partition: "aws",
163-
signingRegion: "us-east-2",
164-
};
165-
break;
166-
case "fips-us-west-1":
167-
regionInfo = {
168-
hostname: "access-analyzer-fips.us-west-1.amazonaws.com",
169-
partition: "aws",
170-
signingRegion: "us-west-1",
171-
};
172-
break;
173-
case "fips-us-west-2":
174-
regionInfo = {
175-
hostname: "access-analyzer-fips.us-west-2.amazonaws.com",
176-
partition: "aws",
177-
signingRegion: "us-west-2",
178-
};
179-
break;
180-
case "me-south-1":
181-
regionInfo = {
182-
hostname: "access-analyzer.me-south-1.amazonaws.com",
183-
partition: "aws",
184-
};
185-
break;
186-
case "sa-east-1":
187-
regionInfo = {
188-
hostname: "access-analyzer.sa-east-1.amazonaws.com",
189-
partition: "aws",
190-
};
191-
break;
192-
case "us-east-1":
193-
regionInfo = {
194-
hostname: "access-analyzer.us-east-1.amazonaws.com",
195-
partition: "aws",
196-
};
197-
break;
198-
case "us-east-2":
199-
regionInfo = {
200-
hostname: "access-analyzer.us-east-2.amazonaws.com",
201-
partition: "aws",
202-
};
203-
break;
204-
case "us-gov-east-1":
205-
regionInfo = {
206-
hostname: "access-analyzer.us-gov-east-1.amazonaws.com",
207-
partition: "aws-us-gov",
208-
signingRegion: "us-gov-east-1",
209-
};
210-
break;
211-
case "us-gov-west-1":
212-
regionInfo = {
213-
hostname: "access-analyzer.us-gov-west-1.amazonaws.com",
214-
partition: "aws-us-gov",
215-
signingRegion: "us-gov-west-1",
216-
};
217-
break;
218-
case "us-west-1":
219-
regionInfo = {
220-
hostname: "access-analyzer.us-west-1.amazonaws.com",
221-
partition: "aws",
222-
};
223-
break;
224-
case "us-west-2":
225-
regionInfo = {
226-
hostname: "access-analyzer.us-west-2.amazonaws.com",
227-
partition: "aws",
228-
};
229-
break;
230-
// Next, try to match partition endpoints.
231-
default:
232-
if (AWS_REGIONS.has(region)) {
233-
regionInfo = {
234-
hostname: AWS_TEMPLATE.replace("{region}", region),
235-
partition: "aws",
236-
};
237-
}
238-
if (AWS_CN_REGIONS.has(region)) {
239-
regionInfo = {
240-
hostname: AWS_CN_TEMPLATE.replace("{region}", region),
241-
partition: "aws-cn",
242-
};
243-
}
244-
if (AWS_ISO_REGIONS.has(region)) {
245-
regionInfo = {
246-
hostname: AWS_ISO_TEMPLATE.replace("{region}", region),
247-
partition: "aws-iso",
248-
};
249-
}
250-
if (AWS_ISO_B_REGIONS.has(region)) {
251-
regionInfo = {
252-
hostname: AWS_ISO_B_TEMPLATE.replace("{region}", region),
253-
partition: "aws-iso-b",
254-
};
255-
}
256-
if (AWS_US_GOV_REGIONS.has(region)) {
257-
regionInfo = {
258-
hostname: AWS_US_GOV_TEMPLATE.replace("{region}", region),
259-
partition: "aws-us-gov",
260-
};
261-
}
262-
// Finally, assume it's an AWS partition endpoint.
263-
if (regionInfo === undefined) {
264-
regionInfo = {
265-
hostname: AWS_TEMPLATE.replace("{region}", region),
266-
partition: "aws",
267-
};
268-
}
269-
}
270-
return Promise.resolve({ signingService: "access-analyzer", ...regionInfo });
35+
const partitionHash: PartitionHash = {
36+
aws: {
37+
regions: [
38+
"af-south-1",
39+
"ap-east-1",
40+
"ap-northeast-1",
41+
"ap-northeast-2",
42+
"ap-northeast-3",
43+
"ap-south-1",
44+
"ap-southeast-1",
45+
"ap-southeast-2",
46+
"ca-central-1",
47+
"eu-central-1",
48+
"eu-north-1",
49+
"eu-south-1",
50+
"eu-west-1",
51+
"eu-west-2",
52+
"eu-west-3",
53+
"fips-ca-central-1",
54+
"fips-us-east-1",
55+
"fips-us-east-2",
56+
"fips-us-west-1",
57+
"fips-us-west-2",
58+
"me-south-1",
59+
"sa-east-1",
60+
"us-east-1",
61+
"us-east-2",
62+
"us-west-1",
63+
"us-west-2",
64+
],
65+
hostname: "access-analyzer.{region}.amazonaws.com",
66+
},
67+
"aws-cn": {
68+
regions: ["cn-north-1", "cn-northwest-1"],
69+
hostname: "access-analyzer.{region}.amazonaws.com.cn",
70+
},
71+
"aws-iso": {
72+
regions: ["us-iso-east-1"],
73+
hostname: "access-analyzer.{region}.c2s.ic.gov",
74+
},
75+
"aws-iso-b": {
76+
regions: ["us-isob-east-1"],
77+
hostname: "access-analyzer.{region}.sc2s.sgov.gov",
78+
},
79+
"aws-us-gov": {
80+
regions: ["us-gov-east-1", "us-gov-west-1"],
81+
hostname: "access-analyzer.{region}.amazonaws.com",
82+
},
27183
};
84+
85+
export const defaultRegionInfoProvider: RegionInfoProvider = async (region: string, options?: any) =>
86+
getRegionInfo(region, {
87+
...options,
88+
signingService: "access-analyzer",
89+
regionHash,
90+
partitionHash,
91+
});

0 commit comments

Comments
 (0)