src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

endpoints.go (16368B)


      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-northeast-1",
    162 			}: endpoints.Endpoint{
    163 				Hostname: "oidc.ap-northeast-1.amazonaws.com",
    164 				CredentialScope: endpoints.CredentialScope{
    165 					Region: "ap-northeast-1",
    166 				},
    167 			},
    168 			endpoints.EndpointKey{
    169 				Region: "ap-northeast-2",
    170 			}: endpoints.Endpoint{
    171 				Hostname: "oidc.ap-northeast-2.amazonaws.com",
    172 				CredentialScope: endpoints.CredentialScope{
    173 					Region: "ap-northeast-2",
    174 				},
    175 			},
    176 			endpoints.EndpointKey{
    177 				Region: "ap-northeast-3",
    178 			}: endpoints.Endpoint{
    179 				Hostname: "oidc.ap-northeast-3.amazonaws.com",
    180 				CredentialScope: endpoints.CredentialScope{
    181 					Region: "ap-northeast-3",
    182 				},
    183 			},
    184 			endpoints.EndpointKey{
    185 				Region: "ap-south-1",
    186 			}: endpoints.Endpoint{
    187 				Hostname: "oidc.ap-south-1.amazonaws.com",
    188 				CredentialScope: endpoints.CredentialScope{
    189 					Region: "ap-south-1",
    190 				},
    191 			},
    192 			endpoints.EndpointKey{
    193 				Region: "ap-south-2",
    194 			}: endpoints.Endpoint{
    195 				Hostname: "oidc.ap-south-2.amazonaws.com",
    196 				CredentialScope: endpoints.CredentialScope{
    197 					Region: "ap-south-2",
    198 				},
    199 			},
    200 			endpoints.EndpointKey{
    201 				Region: "ap-southeast-1",
    202 			}: endpoints.Endpoint{
    203 				Hostname: "oidc.ap-southeast-1.amazonaws.com",
    204 				CredentialScope: endpoints.CredentialScope{
    205 					Region: "ap-southeast-1",
    206 				},
    207 			},
    208 			endpoints.EndpointKey{
    209 				Region: "ap-southeast-2",
    210 			}: endpoints.Endpoint{
    211 				Hostname: "oidc.ap-southeast-2.amazonaws.com",
    212 				CredentialScope: endpoints.CredentialScope{
    213 					Region: "ap-southeast-2",
    214 				},
    215 			},
    216 			endpoints.EndpointKey{
    217 				Region: "ap-southeast-3",
    218 			}: endpoints.Endpoint{
    219 				Hostname: "oidc.ap-southeast-3.amazonaws.com",
    220 				CredentialScope: endpoints.CredentialScope{
    221 					Region: "ap-southeast-3",
    222 				},
    223 			},
    224 			endpoints.EndpointKey{
    225 				Region: "ap-southeast-4",
    226 			}: endpoints.Endpoint{
    227 				Hostname: "oidc.ap-southeast-4.amazonaws.com",
    228 				CredentialScope: endpoints.CredentialScope{
    229 					Region: "ap-southeast-4",
    230 				},
    231 			},
    232 			endpoints.EndpointKey{
    233 				Region: "ap-southeast-5",
    234 			}: endpoints.Endpoint{
    235 				Hostname: "oidc.ap-southeast-5.amazonaws.com",
    236 				CredentialScope: endpoints.CredentialScope{
    237 					Region: "ap-southeast-5",
    238 				},
    239 			},
    240 			endpoints.EndpointKey{
    241 				Region: "ap-southeast-7",
    242 			}: endpoints.Endpoint{},
    243 			endpoints.EndpointKey{
    244 				Region: "ca-central-1",
    245 			}: endpoints.Endpoint{
    246 				Hostname: "oidc.ca-central-1.amazonaws.com",
    247 				CredentialScope: endpoints.CredentialScope{
    248 					Region: "ca-central-1",
    249 				},
    250 			},
    251 			endpoints.EndpointKey{
    252 				Region: "ca-west-1",
    253 			}: endpoints.Endpoint{
    254 				Hostname: "oidc.ca-west-1.amazonaws.com",
    255 				CredentialScope: endpoints.CredentialScope{
    256 					Region: "ca-west-1",
    257 				},
    258 			},
    259 			endpoints.EndpointKey{
    260 				Region: "eu-central-1",
    261 			}: endpoints.Endpoint{
    262 				Hostname: "oidc.eu-central-1.amazonaws.com",
    263 				CredentialScope: endpoints.CredentialScope{
    264 					Region: "eu-central-1",
    265 				},
    266 			},
    267 			endpoints.EndpointKey{
    268 				Region: "eu-central-2",
    269 			}: endpoints.Endpoint{
    270 				Hostname: "oidc.eu-central-2.amazonaws.com",
    271 				CredentialScope: endpoints.CredentialScope{
    272 					Region: "eu-central-2",
    273 				},
    274 			},
    275 			endpoints.EndpointKey{
    276 				Region: "eu-north-1",
    277 			}: endpoints.Endpoint{
    278 				Hostname: "oidc.eu-north-1.amazonaws.com",
    279 				CredentialScope: endpoints.CredentialScope{
    280 					Region: "eu-north-1",
    281 				},
    282 			},
    283 			endpoints.EndpointKey{
    284 				Region: "eu-south-1",
    285 			}: endpoints.Endpoint{
    286 				Hostname: "oidc.eu-south-1.amazonaws.com",
    287 				CredentialScope: endpoints.CredentialScope{
    288 					Region: "eu-south-1",
    289 				},
    290 			},
    291 			endpoints.EndpointKey{
    292 				Region: "eu-south-2",
    293 			}: endpoints.Endpoint{
    294 				Hostname: "oidc.eu-south-2.amazonaws.com",
    295 				CredentialScope: endpoints.CredentialScope{
    296 					Region: "eu-south-2",
    297 				},
    298 			},
    299 			endpoints.EndpointKey{
    300 				Region: "eu-west-1",
    301 			}: endpoints.Endpoint{
    302 				Hostname: "oidc.eu-west-1.amazonaws.com",
    303 				CredentialScope: endpoints.CredentialScope{
    304 					Region: "eu-west-1",
    305 				},
    306 			},
    307 			endpoints.EndpointKey{
    308 				Region: "eu-west-2",
    309 			}: endpoints.Endpoint{
    310 				Hostname: "oidc.eu-west-2.amazonaws.com",
    311 				CredentialScope: endpoints.CredentialScope{
    312 					Region: "eu-west-2",
    313 				},
    314 			},
    315 			endpoints.EndpointKey{
    316 				Region: "eu-west-3",
    317 			}: endpoints.Endpoint{
    318 				Hostname: "oidc.eu-west-3.amazonaws.com",
    319 				CredentialScope: endpoints.CredentialScope{
    320 					Region: "eu-west-3",
    321 				},
    322 			},
    323 			endpoints.EndpointKey{
    324 				Region: "il-central-1",
    325 			}: endpoints.Endpoint{
    326 				Hostname: "oidc.il-central-1.amazonaws.com",
    327 				CredentialScope: endpoints.CredentialScope{
    328 					Region: "il-central-1",
    329 				},
    330 			},
    331 			endpoints.EndpointKey{
    332 				Region: "me-central-1",
    333 			}: endpoints.Endpoint{
    334 				Hostname: "oidc.me-central-1.amazonaws.com",
    335 				CredentialScope: endpoints.CredentialScope{
    336 					Region: "me-central-1",
    337 				},
    338 			},
    339 			endpoints.EndpointKey{
    340 				Region: "me-south-1",
    341 			}: endpoints.Endpoint{
    342 				Hostname: "oidc.me-south-1.amazonaws.com",
    343 				CredentialScope: endpoints.CredentialScope{
    344 					Region: "me-south-1",
    345 				},
    346 			},
    347 			endpoints.EndpointKey{
    348 				Region: "mx-central-1",
    349 			}: endpoints.Endpoint{},
    350 			endpoints.EndpointKey{
    351 				Region: "sa-east-1",
    352 			}: endpoints.Endpoint{
    353 				Hostname: "oidc.sa-east-1.amazonaws.com",
    354 				CredentialScope: endpoints.CredentialScope{
    355 					Region: "sa-east-1",
    356 				},
    357 			},
    358 			endpoints.EndpointKey{
    359 				Region: "us-east-1",
    360 			}: endpoints.Endpoint{
    361 				Hostname: "oidc.us-east-1.amazonaws.com",
    362 				CredentialScope: endpoints.CredentialScope{
    363 					Region: "us-east-1",
    364 				},
    365 			},
    366 			endpoints.EndpointKey{
    367 				Region: "us-east-2",
    368 			}: endpoints.Endpoint{
    369 				Hostname: "oidc.us-east-2.amazonaws.com",
    370 				CredentialScope: endpoints.CredentialScope{
    371 					Region: "us-east-2",
    372 				},
    373 			},
    374 			endpoints.EndpointKey{
    375 				Region: "us-west-1",
    376 			}: endpoints.Endpoint{
    377 				Hostname: "oidc.us-west-1.amazonaws.com",
    378 				CredentialScope: endpoints.CredentialScope{
    379 					Region: "us-west-1",
    380 				},
    381 			},
    382 			endpoints.EndpointKey{
    383 				Region: "us-west-2",
    384 			}: endpoints.Endpoint{
    385 				Hostname: "oidc.us-west-2.amazonaws.com",
    386 				CredentialScope: endpoints.CredentialScope{
    387 					Region: "us-west-2",
    388 				},
    389 			},
    390 		},
    391 	},
    392 	{
    393 		ID: "aws-cn",
    394 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    395 			{
    396 				Variant: endpoints.DualStackVariant,
    397 			}: {
    398 				Hostname:          "oidc.{region}.api.amazonwebservices.com.cn",
    399 				Protocols:         []string{"https"},
    400 				SignatureVersions: []string{"v4"},
    401 			},
    402 			{
    403 				Variant: endpoints.FIPSVariant,
    404 			}: {
    405 				Hostname:          "oidc-fips.{region}.amazonaws.com.cn",
    406 				Protocols:         []string{"https"},
    407 				SignatureVersions: []string{"v4"},
    408 			},
    409 			{
    410 				Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
    411 			}: {
    412 				Hostname:          "oidc-fips.{region}.api.amazonwebservices.com.cn",
    413 				Protocols:         []string{"https"},
    414 				SignatureVersions: []string{"v4"},
    415 			},
    416 			{
    417 				Variant: 0,
    418 			}: {
    419 				Hostname:          "oidc.{region}.amazonaws.com.cn",
    420 				Protocols:         []string{"https"},
    421 				SignatureVersions: []string{"v4"},
    422 			},
    423 		},
    424 		RegionRegex:    partitionRegexp.AwsCn,
    425 		IsRegionalized: true,
    426 		Endpoints: endpoints.Endpoints{
    427 			endpoints.EndpointKey{
    428 				Region: "cn-north-1",
    429 			}: endpoints.Endpoint{
    430 				Hostname: "oidc.cn-north-1.amazonaws.com.cn",
    431 				CredentialScope: endpoints.CredentialScope{
    432 					Region: "cn-north-1",
    433 				},
    434 			},
    435 			endpoints.EndpointKey{
    436 				Region: "cn-northwest-1",
    437 			}: endpoints.Endpoint{
    438 				Hostname: "oidc.cn-northwest-1.amazonaws.com.cn",
    439 				CredentialScope: endpoints.CredentialScope{
    440 					Region: "cn-northwest-1",
    441 				},
    442 			},
    443 		},
    444 	},
    445 	{
    446 		ID: "aws-eusc",
    447 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    448 			{
    449 				Variant: endpoints.FIPSVariant,
    450 			}: {
    451 				Hostname:          "oidc-fips.{region}.amazonaws.eu",
    452 				Protocols:         []string{"https"},
    453 				SignatureVersions: []string{"v4"},
    454 			},
    455 			{
    456 				Variant: 0,
    457 			}: {
    458 				Hostname:          "oidc.{region}.amazonaws.eu",
    459 				Protocols:         []string{"https"},
    460 				SignatureVersions: []string{"v4"},
    461 			},
    462 		},
    463 		RegionRegex:    partitionRegexp.AwsEusc,
    464 		IsRegionalized: true,
    465 	},
    466 	{
    467 		ID: "aws-iso",
    468 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    469 			{
    470 				Variant: endpoints.FIPSVariant,
    471 			}: {
    472 				Hostname:          "oidc-fips.{region}.c2s.ic.gov",
    473 				Protocols:         []string{"https"},
    474 				SignatureVersions: []string{"v4"},
    475 			},
    476 			{
    477 				Variant: 0,
    478 			}: {
    479 				Hostname:          "oidc.{region}.c2s.ic.gov",
    480 				Protocols:         []string{"https"},
    481 				SignatureVersions: []string{"v4"},
    482 			},
    483 		},
    484 		RegionRegex:    partitionRegexp.AwsIso,
    485 		IsRegionalized: true,
    486 	},
    487 	{
    488 		ID: "aws-iso-b",
    489 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    490 			{
    491 				Variant: endpoints.FIPSVariant,
    492 			}: {
    493 				Hostname:          "oidc-fips.{region}.sc2s.sgov.gov",
    494 				Protocols:         []string{"https"},
    495 				SignatureVersions: []string{"v4"},
    496 			},
    497 			{
    498 				Variant: 0,
    499 			}: {
    500 				Hostname:          "oidc.{region}.sc2s.sgov.gov",
    501 				Protocols:         []string{"https"},
    502 				SignatureVersions: []string{"v4"},
    503 			},
    504 		},
    505 		RegionRegex:    partitionRegexp.AwsIsoB,
    506 		IsRegionalized: true,
    507 	},
    508 	{
    509 		ID: "aws-iso-e",
    510 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    511 			{
    512 				Variant: endpoints.FIPSVariant,
    513 			}: {
    514 				Hostname:          "oidc-fips.{region}.cloud.adc-e.uk",
    515 				Protocols:         []string{"https"},
    516 				SignatureVersions: []string{"v4"},
    517 			},
    518 			{
    519 				Variant: 0,
    520 			}: {
    521 				Hostname:          "oidc.{region}.cloud.adc-e.uk",
    522 				Protocols:         []string{"https"},
    523 				SignatureVersions: []string{"v4"},
    524 			},
    525 		},
    526 		RegionRegex:    partitionRegexp.AwsIsoE,
    527 		IsRegionalized: true,
    528 	},
    529 	{
    530 		ID: "aws-iso-f",
    531 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    532 			{
    533 				Variant: endpoints.FIPSVariant,
    534 			}: {
    535 				Hostname:          "oidc-fips.{region}.csp.hci.ic.gov",
    536 				Protocols:         []string{"https"},
    537 				SignatureVersions: []string{"v4"},
    538 			},
    539 			{
    540 				Variant: 0,
    541 			}: {
    542 				Hostname:          "oidc.{region}.csp.hci.ic.gov",
    543 				Protocols:         []string{"https"},
    544 				SignatureVersions: []string{"v4"},
    545 			},
    546 		},
    547 		RegionRegex:    partitionRegexp.AwsIsoF,
    548 		IsRegionalized: true,
    549 	},
    550 	{
    551 		ID: "aws-us-gov",
    552 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    553 			{
    554 				Variant: endpoints.DualStackVariant,
    555 			}: {
    556 				Hostname:          "oidc.{region}.api.aws",
    557 				Protocols:         []string{"https"},
    558 				SignatureVersions: []string{"v4"},
    559 			},
    560 			{
    561 				Variant: endpoints.FIPSVariant,
    562 			}: {
    563 				Hostname:          "oidc-fips.{region}.amazonaws.com",
    564 				Protocols:         []string{"https"},
    565 				SignatureVersions: []string{"v4"},
    566 			},
    567 			{
    568 				Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
    569 			}: {
    570 				Hostname:          "oidc-fips.{region}.api.aws",
    571 				Protocols:         []string{"https"},
    572 				SignatureVersions: []string{"v4"},
    573 			},
    574 			{
    575 				Variant: 0,
    576 			}: {
    577 				Hostname:          "oidc.{region}.amazonaws.com",
    578 				Protocols:         []string{"https"},
    579 				SignatureVersions: []string{"v4"},
    580 			},
    581 		},
    582 		RegionRegex:    partitionRegexp.AwsUsGov,
    583 		IsRegionalized: true,
    584 		Endpoints: endpoints.Endpoints{
    585 			endpoints.EndpointKey{
    586 				Region: "us-gov-east-1",
    587 			}: endpoints.Endpoint{
    588 				Hostname: "oidc.us-gov-east-1.amazonaws.com",
    589 				CredentialScope: endpoints.CredentialScope{
    590 					Region: "us-gov-east-1",
    591 				},
    592 			},
    593 			endpoints.EndpointKey{
    594 				Region: "us-gov-west-1",
    595 			}: endpoints.Endpoint{
    596 				Hostname: "oidc.us-gov-west-1.amazonaws.com",
    597 				CredentialScope: endpoints.CredentialScope{
    598 					Region: "us-gov-west-1",
    599 				},
    600 			},
    601 		},
    602 	},
    603 }