endpoints.go raw
1 // Code generated by smithy-go-codegen DO NOT EDIT.
2
3 package endpoints
4
5 import (
6 "github.com/aws/aws-sdk-go-v2/aws"
7 endpoints "github.com/aws/aws-sdk-go-v2/internal/endpoints/v2"
8 "github.com/aws/smithy-go/logging"
9 "regexp"
10 )
11
12 // Options is the endpoint resolver configuration options
13 type Options struct {
14 // Logger is a logging implementation that log events should be sent to.
15 Logger logging.Logger
16
17 // LogDeprecated indicates that deprecated endpoints should be logged to the
18 // provided logger.
19 LogDeprecated bool
20
21 // ResolvedRegion is used to override the region to be resolved, rather then the
22 // using the value passed to the ResolveEndpoint method. This value is used by the
23 // SDK to translate regions like fips-us-east-1 or us-east-1-fips to an alternative
24 // name. You must not set this value directly in your application.
25 ResolvedRegion string
26
27 // DisableHTTPS informs the resolver to return an endpoint that does not use the
28 // HTTPS scheme.
29 DisableHTTPS bool
30
31 // UseDualStackEndpoint specifies the resolver must resolve a dual-stack endpoint.
32 UseDualStackEndpoint aws.DualStackEndpointState
33
34 // UseFIPSEndpoint specifies the resolver must resolve a FIPS endpoint.
35 UseFIPSEndpoint aws.FIPSEndpointState
36 }
37
38 func (o Options) GetResolvedRegion() string {
39 return o.ResolvedRegion
40 }
41
42 func (o Options) GetDisableHTTPS() bool {
43 return o.DisableHTTPS
44 }
45
46 func (o Options) GetUseDualStackEndpoint() aws.DualStackEndpointState {
47 return o.UseDualStackEndpoint
48 }
49
50 func (o Options) GetUseFIPSEndpoint() aws.FIPSEndpointState {
51 return o.UseFIPSEndpoint
52 }
53
54 func transformToSharedOptions(options Options) endpoints.Options {
55 return endpoints.Options{
56 Logger: options.Logger,
57 LogDeprecated: options.LogDeprecated,
58 ResolvedRegion: options.ResolvedRegion,
59 DisableHTTPS: options.DisableHTTPS,
60 UseDualStackEndpoint: options.UseDualStackEndpoint,
61 UseFIPSEndpoint: options.UseFIPSEndpoint,
62 }
63 }
64
65 // Resolver SSO OIDC endpoint resolver
66 type Resolver struct {
67 partitions endpoints.Partitions
68 }
69
70 // ResolveEndpoint resolves the service endpoint for the given region and options
71 func (r *Resolver) ResolveEndpoint(region string, options Options) (endpoint aws.Endpoint, err error) {
72 if len(region) == 0 {
73 return endpoint, &aws.MissingRegionError{}
74 }
75
76 opt := transformToSharedOptions(options)
77 return r.partitions.ResolveEndpoint(region, opt)
78 }
79
80 // New returns a new Resolver
81 func New() *Resolver {
82 return &Resolver{
83 partitions: defaultPartitions,
84 }
85 }
86
87 var partitionRegexp = struct {
88 Aws *regexp.Regexp
89 AwsCn *regexp.Regexp
90 AwsEusc *regexp.Regexp
91 AwsIso *regexp.Regexp
92 AwsIsoB *regexp.Regexp
93 AwsIsoE *regexp.Regexp
94 AwsIsoF *regexp.Regexp
95 AwsUsGov *regexp.Regexp
96 }{
97
98 Aws: regexp.MustCompile("^(us|eu|ap|sa|ca|me|af|il|mx)\\-\\w+\\-\\d+$"),
99 AwsCn: regexp.MustCompile("^cn\\-\\w+\\-\\d+$"),
100 AwsEusc: regexp.MustCompile("^eusc\\-(de)\\-\\w+\\-\\d+$"),
101 AwsIso: regexp.MustCompile("^us\\-iso\\-\\w+\\-\\d+$"),
102 AwsIsoB: regexp.MustCompile("^us\\-isob\\-\\w+\\-\\d+$"),
103 AwsIsoE: regexp.MustCompile("^eu\\-isoe\\-\\w+\\-\\d+$"),
104 AwsIsoF: regexp.MustCompile("^us\\-isof\\-\\w+\\-\\d+$"),
105 AwsUsGov: regexp.MustCompile("^us\\-gov\\-\\w+\\-\\d+$"),
106 }
107
108 var defaultPartitions = endpoints.Partitions{
109 {
110 ID: "aws",
111 Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
112 {
113 Variant: endpoints.DualStackVariant,
114 }: {
115 Hostname: "oidc.{region}.api.aws",
116 Protocols: []string{"https"},
117 SignatureVersions: []string{"v4"},
118 },
119 {
120 Variant: endpoints.FIPSVariant,
121 }: {
122 Hostname: "oidc-fips.{region}.amazonaws.com",
123 Protocols: []string{"https"},
124 SignatureVersions: []string{"v4"},
125 },
126 {
127 Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
128 }: {
129 Hostname: "oidc-fips.{region}.api.aws",
130 Protocols: []string{"https"},
131 SignatureVersions: []string{"v4"},
132 },
133 {
134 Variant: 0,
135 }: {
136 Hostname: "oidc.{region}.amazonaws.com",
137 Protocols: []string{"https"},
138 SignatureVersions: []string{"v4"},
139 },
140 },
141 RegionRegex: partitionRegexp.Aws,
142 IsRegionalized: true,
143 Endpoints: endpoints.Endpoints{
144 endpoints.EndpointKey{
145 Region: "af-south-1",
146 }: endpoints.Endpoint{
147 Hostname: "oidc.af-south-1.amazonaws.com",
148 CredentialScope: endpoints.CredentialScope{
149 Region: "af-south-1",
150 },
151 },
152 endpoints.EndpointKey{
153 Region: "ap-east-1",
154 }: endpoints.Endpoint{
155 Hostname: "oidc.ap-east-1.amazonaws.com",
156 CredentialScope: endpoints.CredentialScope{
157 Region: "ap-east-1",
158 },
159 },
160 endpoints.EndpointKey{
161 Region: "ap-east-2",
162 }: endpoints.Endpoint{},
163 endpoints.EndpointKey{
164 Region: "ap-northeast-1",
165 }: endpoints.Endpoint{
166 Hostname: "oidc.ap-northeast-1.amazonaws.com",
167 CredentialScope: endpoints.CredentialScope{
168 Region: "ap-northeast-1",
169 },
170 },
171 endpoints.EndpointKey{
172 Region: "ap-northeast-2",
173 }: endpoints.Endpoint{
174 Hostname: "oidc.ap-northeast-2.amazonaws.com",
175 CredentialScope: endpoints.CredentialScope{
176 Region: "ap-northeast-2",
177 },
178 },
179 endpoints.EndpointKey{
180 Region: "ap-northeast-3",
181 }: endpoints.Endpoint{
182 Hostname: "oidc.ap-northeast-3.amazonaws.com",
183 CredentialScope: endpoints.CredentialScope{
184 Region: "ap-northeast-3",
185 },
186 },
187 endpoints.EndpointKey{
188 Region: "ap-south-1",
189 }: endpoints.Endpoint{
190 Hostname: "oidc.ap-south-1.amazonaws.com",
191 CredentialScope: endpoints.CredentialScope{
192 Region: "ap-south-1",
193 },
194 },
195 endpoints.EndpointKey{
196 Region: "ap-south-2",
197 }: endpoints.Endpoint{
198 Hostname: "oidc.ap-south-2.amazonaws.com",
199 CredentialScope: endpoints.CredentialScope{
200 Region: "ap-south-2",
201 },
202 },
203 endpoints.EndpointKey{
204 Region: "ap-southeast-1",
205 }: endpoints.Endpoint{
206 Hostname: "oidc.ap-southeast-1.amazonaws.com",
207 CredentialScope: endpoints.CredentialScope{
208 Region: "ap-southeast-1",
209 },
210 },
211 endpoints.EndpointKey{
212 Region: "ap-southeast-2",
213 }: endpoints.Endpoint{
214 Hostname: "oidc.ap-southeast-2.amazonaws.com",
215 CredentialScope: endpoints.CredentialScope{
216 Region: "ap-southeast-2",
217 },
218 },
219 endpoints.EndpointKey{
220 Region: "ap-southeast-3",
221 }: endpoints.Endpoint{
222 Hostname: "oidc.ap-southeast-3.amazonaws.com",
223 CredentialScope: endpoints.CredentialScope{
224 Region: "ap-southeast-3",
225 },
226 },
227 endpoints.EndpointKey{
228 Region: "ap-southeast-4",
229 }: endpoints.Endpoint{
230 Hostname: "oidc.ap-southeast-4.amazonaws.com",
231 CredentialScope: endpoints.CredentialScope{
232 Region: "ap-southeast-4",
233 },
234 },
235 endpoints.EndpointKey{
236 Region: "ap-southeast-5",
237 }: endpoints.Endpoint{
238 Hostname: "oidc.ap-southeast-5.amazonaws.com",
239 CredentialScope: endpoints.CredentialScope{
240 Region: "ap-southeast-5",
241 },
242 },
243 endpoints.EndpointKey{
244 Region: "ap-southeast-7",
245 }: endpoints.Endpoint{},
246 endpoints.EndpointKey{
247 Region: "ca-central-1",
248 }: endpoints.Endpoint{
249 Hostname: "oidc.ca-central-1.amazonaws.com",
250 CredentialScope: endpoints.CredentialScope{
251 Region: "ca-central-1",
252 },
253 },
254 endpoints.EndpointKey{
255 Region: "ca-west-1",
256 }: endpoints.Endpoint{
257 Hostname: "oidc.ca-west-1.amazonaws.com",
258 CredentialScope: endpoints.CredentialScope{
259 Region: "ca-west-1",
260 },
261 },
262 endpoints.EndpointKey{
263 Region: "eu-central-1",
264 }: endpoints.Endpoint{
265 Hostname: "oidc.eu-central-1.amazonaws.com",
266 CredentialScope: endpoints.CredentialScope{
267 Region: "eu-central-1",
268 },
269 },
270 endpoints.EndpointKey{
271 Region: "eu-central-2",
272 }: endpoints.Endpoint{
273 Hostname: "oidc.eu-central-2.amazonaws.com",
274 CredentialScope: endpoints.CredentialScope{
275 Region: "eu-central-2",
276 },
277 },
278 endpoints.EndpointKey{
279 Region: "eu-north-1",
280 }: endpoints.Endpoint{
281 Hostname: "oidc.eu-north-1.amazonaws.com",
282 CredentialScope: endpoints.CredentialScope{
283 Region: "eu-north-1",
284 },
285 },
286 endpoints.EndpointKey{
287 Region: "eu-south-1",
288 }: endpoints.Endpoint{
289 Hostname: "oidc.eu-south-1.amazonaws.com",
290 CredentialScope: endpoints.CredentialScope{
291 Region: "eu-south-1",
292 },
293 },
294 endpoints.EndpointKey{
295 Region: "eu-south-2",
296 }: endpoints.Endpoint{
297 Hostname: "oidc.eu-south-2.amazonaws.com",
298 CredentialScope: endpoints.CredentialScope{
299 Region: "eu-south-2",
300 },
301 },
302 endpoints.EndpointKey{
303 Region: "eu-west-1",
304 }: endpoints.Endpoint{
305 Hostname: "oidc.eu-west-1.amazonaws.com",
306 CredentialScope: endpoints.CredentialScope{
307 Region: "eu-west-1",
308 },
309 },
310 endpoints.EndpointKey{
311 Region: "eu-west-2",
312 }: endpoints.Endpoint{
313 Hostname: "oidc.eu-west-2.amazonaws.com",
314 CredentialScope: endpoints.CredentialScope{
315 Region: "eu-west-2",
316 },
317 },
318 endpoints.EndpointKey{
319 Region: "eu-west-3",
320 }: endpoints.Endpoint{
321 Hostname: "oidc.eu-west-3.amazonaws.com",
322 CredentialScope: endpoints.CredentialScope{
323 Region: "eu-west-3",
324 },
325 },
326 endpoints.EndpointKey{
327 Region: "il-central-1",
328 }: endpoints.Endpoint{
329 Hostname: "oidc.il-central-1.amazonaws.com",
330 CredentialScope: endpoints.CredentialScope{
331 Region: "il-central-1",
332 },
333 },
334 endpoints.EndpointKey{
335 Region: "me-central-1",
336 }: endpoints.Endpoint{
337 Hostname: "oidc.me-central-1.amazonaws.com",
338 CredentialScope: endpoints.CredentialScope{
339 Region: "me-central-1",
340 },
341 },
342 endpoints.EndpointKey{
343 Region: "me-south-1",
344 }: endpoints.Endpoint{
345 Hostname: "oidc.me-south-1.amazonaws.com",
346 CredentialScope: endpoints.CredentialScope{
347 Region: "me-south-1",
348 },
349 },
350 endpoints.EndpointKey{
351 Region: "mx-central-1",
352 }: endpoints.Endpoint{},
353 endpoints.EndpointKey{
354 Region: "sa-east-1",
355 }: endpoints.Endpoint{
356 Hostname: "oidc.sa-east-1.amazonaws.com",
357 CredentialScope: endpoints.CredentialScope{
358 Region: "sa-east-1",
359 },
360 },
361 endpoints.EndpointKey{
362 Region: "us-east-1",
363 }: endpoints.Endpoint{
364 Hostname: "oidc.us-east-1.amazonaws.com",
365 CredentialScope: endpoints.CredentialScope{
366 Region: "us-east-1",
367 },
368 },
369 endpoints.EndpointKey{
370 Region: "us-east-2",
371 }: endpoints.Endpoint{
372 Hostname: "oidc.us-east-2.amazonaws.com",
373 CredentialScope: endpoints.CredentialScope{
374 Region: "us-east-2",
375 },
376 },
377 endpoints.EndpointKey{
378 Region: "us-west-1",
379 }: endpoints.Endpoint{
380 Hostname: "oidc.us-west-1.amazonaws.com",
381 CredentialScope: endpoints.CredentialScope{
382 Region: "us-west-1",
383 },
384 },
385 endpoints.EndpointKey{
386 Region: "us-west-2",
387 }: endpoints.Endpoint{
388 Hostname: "oidc.us-west-2.amazonaws.com",
389 CredentialScope: endpoints.CredentialScope{
390 Region: "us-west-2",
391 },
392 },
393 },
394 },
395 {
396 ID: "aws-cn",
397 Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
398 {
399 Variant: endpoints.DualStackVariant,
400 }: {
401 Hostname: "oidc.{region}.api.amazonwebservices.com.cn",
402 Protocols: []string{"https"},
403 SignatureVersions: []string{"v4"},
404 },
405 {
406 Variant: endpoints.FIPSVariant,
407 }: {
408 Hostname: "oidc-fips.{region}.amazonaws.com.cn",
409 Protocols: []string{"https"},
410 SignatureVersions: []string{"v4"},
411 },
412 {
413 Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
414 }: {
415 Hostname: "oidc-fips.{region}.api.amazonwebservices.com.cn",
416 Protocols: []string{"https"},
417 SignatureVersions: []string{"v4"},
418 },
419 {
420 Variant: 0,
421 }: {
422 Hostname: "oidc.{region}.amazonaws.com.cn",
423 Protocols: []string{"https"},
424 SignatureVersions: []string{"v4"},
425 },
426 },
427 RegionRegex: partitionRegexp.AwsCn,
428 IsRegionalized: true,
429 Endpoints: endpoints.Endpoints{
430 endpoints.EndpointKey{
431 Region: "cn-north-1",
432 }: endpoints.Endpoint{
433 Hostname: "oidc.cn-north-1.amazonaws.com.cn",
434 CredentialScope: endpoints.CredentialScope{
435 Region: "cn-north-1",
436 },
437 },
438 endpoints.EndpointKey{
439 Region: "cn-northwest-1",
440 }: endpoints.Endpoint{
441 Hostname: "oidc.cn-northwest-1.amazonaws.com.cn",
442 CredentialScope: endpoints.CredentialScope{
443 Region: "cn-northwest-1",
444 },
445 },
446 },
447 },
448 {
449 ID: "aws-eusc",
450 Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
451 {
452 Variant: endpoints.DualStackVariant,
453 }: {
454 Hostname: "oidc.{region}.api.amazonwebservices.eu",
455 Protocols: []string{"https"},
456 SignatureVersions: []string{"v4"},
457 },
458 {
459 Variant: endpoints.FIPSVariant,
460 }: {
461 Hostname: "oidc-fips.{region}.amazonaws.eu",
462 Protocols: []string{"https"},
463 SignatureVersions: []string{"v4"},
464 },
465 {
466 Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
467 }: {
468 Hostname: "oidc-fips.{region}.api.amazonwebservices.eu",
469 Protocols: []string{"https"},
470 SignatureVersions: []string{"v4"},
471 },
472 {
473 Variant: 0,
474 }: {
475 Hostname: "oidc.{region}.amazonaws.eu",
476 Protocols: []string{"https"},
477 SignatureVersions: []string{"v4"},
478 },
479 },
480 RegionRegex: partitionRegexp.AwsEusc,
481 IsRegionalized: true,
482 },
483 {
484 ID: "aws-iso",
485 Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
486 {
487 Variant: endpoints.FIPSVariant,
488 }: {
489 Hostname: "oidc-fips.{region}.c2s.ic.gov",
490 Protocols: []string{"https"},
491 SignatureVersions: []string{"v4"},
492 },
493 {
494 Variant: 0,
495 }: {
496 Hostname: "oidc.{region}.c2s.ic.gov",
497 Protocols: []string{"https"},
498 SignatureVersions: []string{"v4"},
499 },
500 },
501 RegionRegex: partitionRegexp.AwsIso,
502 IsRegionalized: true,
503 },
504 {
505 ID: "aws-iso-b",
506 Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
507 {
508 Variant: endpoints.FIPSVariant,
509 }: {
510 Hostname: "oidc-fips.{region}.sc2s.sgov.gov",
511 Protocols: []string{"https"},
512 SignatureVersions: []string{"v4"},
513 },
514 {
515 Variant: 0,
516 }: {
517 Hostname: "oidc.{region}.sc2s.sgov.gov",
518 Protocols: []string{"https"},
519 SignatureVersions: []string{"v4"},
520 },
521 },
522 RegionRegex: partitionRegexp.AwsIsoB,
523 IsRegionalized: true,
524 },
525 {
526 ID: "aws-iso-e",
527 Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
528 {
529 Variant: endpoints.FIPSVariant,
530 }: {
531 Hostname: "oidc-fips.{region}.cloud.adc-e.uk",
532 Protocols: []string{"https"},
533 SignatureVersions: []string{"v4"},
534 },
535 {
536 Variant: 0,
537 }: {
538 Hostname: "oidc.{region}.cloud.adc-e.uk",
539 Protocols: []string{"https"},
540 SignatureVersions: []string{"v4"},
541 },
542 },
543 RegionRegex: partitionRegexp.AwsIsoE,
544 IsRegionalized: true,
545 },
546 {
547 ID: "aws-iso-f",
548 Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
549 {
550 Variant: endpoints.FIPSVariant,
551 }: {
552 Hostname: "oidc-fips.{region}.csp.hci.ic.gov",
553 Protocols: []string{"https"},
554 SignatureVersions: []string{"v4"},
555 },
556 {
557 Variant: 0,
558 }: {
559 Hostname: "oidc.{region}.csp.hci.ic.gov",
560 Protocols: []string{"https"},
561 SignatureVersions: []string{"v4"},
562 },
563 },
564 RegionRegex: partitionRegexp.AwsIsoF,
565 IsRegionalized: true,
566 },
567 {
568 ID: "aws-us-gov",
569 Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
570 {
571 Variant: endpoints.DualStackVariant,
572 }: {
573 Hostname: "oidc.{region}.api.aws",
574 Protocols: []string{"https"},
575 SignatureVersions: []string{"v4"},
576 },
577 {
578 Variant: endpoints.FIPSVariant,
579 }: {
580 Hostname: "oidc-fips.{region}.amazonaws.com",
581 Protocols: []string{"https"},
582 SignatureVersions: []string{"v4"},
583 },
584 {
585 Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
586 }: {
587 Hostname: "oidc-fips.{region}.api.aws",
588 Protocols: []string{"https"},
589 SignatureVersions: []string{"v4"},
590 },
591 {
592 Variant: 0,
593 }: {
594 Hostname: "oidc.{region}.amazonaws.com",
595 Protocols: []string{"https"},
596 SignatureVersions: []string{"v4"},
597 },
598 },
599 RegionRegex: partitionRegexp.AwsUsGov,
600 IsRegionalized: true,
601 Endpoints: endpoints.Endpoints{
602 endpoints.EndpointKey{
603 Region: "us-gov-east-1",
604 }: endpoints.Endpoint{
605 Hostname: "oidc.us-gov-east-1.amazonaws.com",
606 CredentialScope: endpoints.CredentialScope{
607 Region: "us-gov-east-1",
608 },
609 },
610 endpoints.EndpointKey{
611 Region: "us-gov-west-1",
612 }: endpoints.Endpoint{
613 Hostname: "oidc.us-gov-west-1.amazonaws.com",
614 CredentialScope: endpoints.CredentialScope{
615 Region: "us-gov-west-1",
616 },
617 },
618 },
619 },
620 }
621