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