src

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

endpoints.go (14798B)


      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 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 	AwsIso   *regexp.Regexp
     91 	AwsIsoB  *regexp.Regexp
     92 	AwsIsoE  *regexp.Regexp
     93 	AwsIsoF  *regexp.Regexp
     94 	AwsUsGov *regexp.Regexp
     95 }{
     96 
     97 	Aws:      regexp.MustCompile("^(us|eu|ap|sa|ca|me|af|il)\\-\\w+\\-\\d+$"),
     98 	AwsCn:    regexp.MustCompile("^cn\\-\\w+\\-\\d+$"),
     99 	AwsIso:   regexp.MustCompile("^us\\-iso\\-\\w+\\-\\d+$"),
    100 	AwsIsoB:  regexp.MustCompile("^us\\-isob\\-\\w+\\-\\d+$"),
    101 	AwsIsoE:  regexp.MustCompile("^eu\\-isoe\\-\\w+\\-\\d+$"),
    102 	AwsIsoF:  regexp.MustCompile("^us\\-isof\\-\\w+\\-\\d+$"),
    103 	AwsUsGov: regexp.MustCompile("^us\\-gov\\-\\w+\\-\\d+$"),
    104 }
    105 
    106 var defaultPartitions = endpoints.Partitions{
    107 	{
    108 		ID: "aws",
    109 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    110 			{
    111 				Variant: endpoints.DualStackVariant,
    112 			}: {
    113 				Hostname:          "portal.sso.{region}.api.aws",
    114 				Protocols:         []string{"https"},
    115 				SignatureVersions: []string{"v4"},
    116 			},
    117 			{
    118 				Variant: endpoints.FIPSVariant,
    119 			}: {
    120 				Hostname:          "portal.sso-fips.{region}.amazonaws.com",
    121 				Protocols:         []string{"https"},
    122 				SignatureVersions: []string{"v4"},
    123 			},
    124 			{
    125 				Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
    126 			}: {
    127 				Hostname:          "portal.sso-fips.{region}.api.aws",
    128 				Protocols:         []string{"https"},
    129 				SignatureVersions: []string{"v4"},
    130 			},
    131 			{
    132 				Variant: 0,
    133 			}: {
    134 				Hostname:          "portal.sso.{region}.amazonaws.com",
    135 				Protocols:         []string{"https"},
    136 				SignatureVersions: []string{"v4"},
    137 			},
    138 		},
    139 		RegionRegex:    partitionRegexp.Aws,
    140 		IsRegionalized: true,
    141 		Endpoints: endpoints.Endpoints{
    142 			endpoints.EndpointKey{
    143 				Region: "af-south-1",
    144 			}: endpoints.Endpoint{
    145 				Hostname: "portal.sso.af-south-1.amazonaws.com",
    146 				CredentialScope: endpoints.CredentialScope{
    147 					Region: "af-south-1",
    148 				},
    149 			},
    150 			endpoints.EndpointKey{
    151 				Region: "ap-east-1",
    152 			}: endpoints.Endpoint{
    153 				Hostname: "portal.sso.ap-east-1.amazonaws.com",
    154 				CredentialScope: endpoints.CredentialScope{
    155 					Region: "ap-east-1",
    156 				},
    157 			},
    158 			endpoints.EndpointKey{
    159 				Region: "ap-northeast-1",
    160 			}: endpoints.Endpoint{
    161 				Hostname: "portal.sso.ap-northeast-1.amazonaws.com",
    162 				CredentialScope: endpoints.CredentialScope{
    163 					Region: "ap-northeast-1",
    164 				},
    165 			},
    166 			endpoints.EndpointKey{
    167 				Region: "ap-northeast-2",
    168 			}: endpoints.Endpoint{
    169 				Hostname: "portal.sso.ap-northeast-2.amazonaws.com",
    170 				CredentialScope: endpoints.CredentialScope{
    171 					Region: "ap-northeast-2",
    172 				},
    173 			},
    174 			endpoints.EndpointKey{
    175 				Region: "ap-northeast-3",
    176 			}: endpoints.Endpoint{
    177 				Hostname: "portal.sso.ap-northeast-3.amazonaws.com",
    178 				CredentialScope: endpoints.CredentialScope{
    179 					Region: "ap-northeast-3",
    180 				},
    181 			},
    182 			endpoints.EndpointKey{
    183 				Region: "ap-south-1",
    184 			}: endpoints.Endpoint{
    185 				Hostname: "portal.sso.ap-south-1.amazonaws.com",
    186 				CredentialScope: endpoints.CredentialScope{
    187 					Region: "ap-south-1",
    188 				},
    189 			},
    190 			endpoints.EndpointKey{
    191 				Region: "ap-southeast-1",
    192 			}: endpoints.Endpoint{
    193 				Hostname: "portal.sso.ap-southeast-1.amazonaws.com",
    194 				CredentialScope: endpoints.CredentialScope{
    195 					Region: "ap-southeast-1",
    196 				},
    197 			},
    198 			endpoints.EndpointKey{
    199 				Region: "ap-southeast-2",
    200 			}: endpoints.Endpoint{
    201 				Hostname: "portal.sso.ap-southeast-2.amazonaws.com",
    202 				CredentialScope: endpoints.CredentialScope{
    203 					Region: "ap-southeast-2",
    204 				},
    205 			},
    206 			endpoints.EndpointKey{
    207 				Region: "ap-southeast-3",
    208 			}: endpoints.Endpoint{
    209 				Hostname: "portal.sso.ap-southeast-3.amazonaws.com",
    210 				CredentialScope: endpoints.CredentialScope{
    211 					Region: "ap-southeast-3",
    212 				},
    213 			},
    214 			endpoints.EndpointKey{
    215 				Region: "ca-central-1",
    216 			}: endpoints.Endpoint{
    217 				Hostname: "portal.sso.ca-central-1.amazonaws.com",
    218 				CredentialScope: endpoints.CredentialScope{
    219 					Region: "ca-central-1",
    220 				},
    221 			},
    222 			endpoints.EndpointKey{
    223 				Region: "eu-central-1",
    224 			}: endpoints.Endpoint{
    225 				Hostname: "portal.sso.eu-central-1.amazonaws.com",
    226 				CredentialScope: endpoints.CredentialScope{
    227 					Region: "eu-central-1",
    228 				},
    229 			},
    230 			endpoints.EndpointKey{
    231 				Region: "eu-central-2",
    232 			}: endpoints.Endpoint{
    233 				Hostname: "portal.sso.eu-central-2.amazonaws.com",
    234 				CredentialScope: endpoints.CredentialScope{
    235 					Region: "eu-central-2",
    236 				},
    237 			},
    238 			endpoints.EndpointKey{
    239 				Region: "eu-north-1",
    240 			}: endpoints.Endpoint{
    241 				Hostname: "portal.sso.eu-north-1.amazonaws.com",
    242 				CredentialScope: endpoints.CredentialScope{
    243 					Region: "eu-north-1",
    244 				},
    245 			},
    246 			endpoints.EndpointKey{
    247 				Region: "eu-south-1",
    248 			}: endpoints.Endpoint{
    249 				Hostname: "portal.sso.eu-south-1.amazonaws.com",
    250 				CredentialScope: endpoints.CredentialScope{
    251 					Region: "eu-south-1",
    252 				},
    253 			},
    254 			endpoints.EndpointKey{
    255 				Region: "eu-west-1",
    256 			}: endpoints.Endpoint{
    257 				Hostname: "portal.sso.eu-west-1.amazonaws.com",
    258 				CredentialScope: endpoints.CredentialScope{
    259 					Region: "eu-west-1",
    260 				},
    261 			},
    262 			endpoints.EndpointKey{
    263 				Region: "eu-west-2",
    264 			}: endpoints.Endpoint{
    265 				Hostname: "portal.sso.eu-west-2.amazonaws.com",
    266 				CredentialScope: endpoints.CredentialScope{
    267 					Region: "eu-west-2",
    268 				},
    269 			},
    270 			endpoints.EndpointKey{
    271 				Region: "eu-west-3",
    272 			}: endpoints.Endpoint{
    273 				Hostname: "portal.sso.eu-west-3.amazonaws.com",
    274 				CredentialScope: endpoints.CredentialScope{
    275 					Region: "eu-west-3",
    276 				},
    277 			},
    278 			endpoints.EndpointKey{
    279 				Region: "il-central-1",
    280 			}: endpoints.Endpoint{
    281 				Hostname: "portal.sso.il-central-1.amazonaws.com",
    282 				CredentialScope: endpoints.CredentialScope{
    283 					Region: "il-central-1",
    284 				},
    285 			},
    286 			endpoints.EndpointKey{
    287 				Region: "me-central-1",
    288 			}: endpoints.Endpoint{
    289 				Hostname: "portal.sso.me-central-1.amazonaws.com",
    290 				CredentialScope: endpoints.CredentialScope{
    291 					Region: "me-central-1",
    292 				},
    293 			},
    294 			endpoints.EndpointKey{
    295 				Region: "me-south-1",
    296 			}: endpoints.Endpoint{
    297 				Hostname: "portal.sso.me-south-1.amazonaws.com",
    298 				CredentialScope: endpoints.CredentialScope{
    299 					Region: "me-south-1",
    300 				},
    301 			},
    302 			endpoints.EndpointKey{
    303 				Region: "sa-east-1",
    304 			}: endpoints.Endpoint{
    305 				Hostname: "portal.sso.sa-east-1.amazonaws.com",
    306 				CredentialScope: endpoints.CredentialScope{
    307 					Region: "sa-east-1",
    308 				},
    309 			},
    310 			endpoints.EndpointKey{
    311 				Region: "us-east-1",
    312 			}: endpoints.Endpoint{
    313 				Hostname: "portal.sso.us-east-1.amazonaws.com",
    314 				CredentialScope: endpoints.CredentialScope{
    315 					Region: "us-east-1",
    316 				},
    317 			},
    318 			endpoints.EndpointKey{
    319 				Region: "us-east-2",
    320 			}: endpoints.Endpoint{
    321 				Hostname: "portal.sso.us-east-2.amazonaws.com",
    322 				CredentialScope: endpoints.CredentialScope{
    323 					Region: "us-east-2",
    324 				},
    325 			},
    326 			endpoints.EndpointKey{
    327 				Region: "us-west-1",
    328 			}: endpoints.Endpoint{
    329 				Hostname: "portal.sso.us-west-1.amazonaws.com",
    330 				CredentialScope: endpoints.CredentialScope{
    331 					Region: "us-west-1",
    332 				},
    333 			},
    334 			endpoints.EndpointKey{
    335 				Region: "us-west-2",
    336 			}: endpoints.Endpoint{
    337 				Hostname: "portal.sso.us-west-2.amazonaws.com",
    338 				CredentialScope: endpoints.CredentialScope{
    339 					Region: "us-west-2",
    340 				},
    341 			},
    342 		},
    343 	},
    344 	{
    345 		ID: "aws-cn",
    346 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    347 			{
    348 				Variant: endpoints.DualStackVariant,
    349 			}: {
    350 				Hostname:          "portal.sso.{region}.api.amazonwebservices.com.cn",
    351 				Protocols:         []string{"https"},
    352 				SignatureVersions: []string{"v4"},
    353 			},
    354 			{
    355 				Variant: endpoints.FIPSVariant,
    356 			}: {
    357 				Hostname:          "portal.sso-fips.{region}.amazonaws.com.cn",
    358 				Protocols:         []string{"https"},
    359 				SignatureVersions: []string{"v4"},
    360 			},
    361 			{
    362 				Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
    363 			}: {
    364 				Hostname:          "portal.sso-fips.{region}.api.amazonwebservices.com.cn",
    365 				Protocols:         []string{"https"},
    366 				SignatureVersions: []string{"v4"},
    367 			},
    368 			{
    369 				Variant: 0,
    370 			}: {
    371 				Hostname:          "portal.sso.{region}.amazonaws.com.cn",
    372 				Protocols:         []string{"https"},
    373 				SignatureVersions: []string{"v4"},
    374 			},
    375 		},
    376 		RegionRegex:    partitionRegexp.AwsCn,
    377 		IsRegionalized: true,
    378 		Endpoints: endpoints.Endpoints{
    379 			endpoints.EndpointKey{
    380 				Region: "cn-north-1",
    381 			}: endpoints.Endpoint{
    382 				Hostname: "portal.sso.cn-north-1.amazonaws.com.cn",
    383 				CredentialScope: endpoints.CredentialScope{
    384 					Region: "cn-north-1",
    385 				},
    386 			},
    387 			endpoints.EndpointKey{
    388 				Region: "cn-northwest-1",
    389 			}: endpoints.Endpoint{
    390 				Hostname: "portal.sso.cn-northwest-1.amazonaws.com.cn",
    391 				CredentialScope: endpoints.CredentialScope{
    392 					Region: "cn-northwest-1",
    393 				},
    394 			},
    395 		},
    396 	},
    397 	{
    398 		ID: "aws-iso",
    399 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    400 			{
    401 				Variant: endpoints.FIPSVariant,
    402 			}: {
    403 				Hostname:          "portal.sso-fips.{region}.c2s.ic.gov",
    404 				Protocols:         []string{"https"},
    405 				SignatureVersions: []string{"v4"},
    406 			},
    407 			{
    408 				Variant: 0,
    409 			}: {
    410 				Hostname:          "portal.sso.{region}.c2s.ic.gov",
    411 				Protocols:         []string{"https"},
    412 				SignatureVersions: []string{"v4"},
    413 			},
    414 		},
    415 		RegionRegex:    partitionRegexp.AwsIso,
    416 		IsRegionalized: true,
    417 	},
    418 	{
    419 		ID: "aws-iso-b",
    420 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    421 			{
    422 				Variant: endpoints.FIPSVariant,
    423 			}: {
    424 				Hostname:          "portal.sso-fips.{region}.sc2s.sgov.gov",
    425 				Protocols:         []string{"https"},
    426 				SignatureVersions: []string{"v4"},
    427 			},
    428 			{
    429 				Variant: 0,
    430 			}: {
    431 				Hostname:          "portal.sso.{region}.sc2s.sgov.gov",
    432 				Protocols:         []string{"https"},
    433 				SignatureVersions: []string{"v4"},
    434 			},
    435 		},
    436 		RegionRegex:    partitionRegexp.AwsIsoB,
    437 		IsRegionalized: true,
    438 	},
    439 	{
    440 		ID: "aws-iso-e",
    441 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    442 			{
    443 				Variant: endpoints.FIPSVariant,
    444 			}: {
    445 				Hostname:          "portal.sso-fips.{region}.cloud.adc-e.uk",
    446 				Protocols:         []string{"https"},
    447 				SignatureVersions: []string{"v4"},
    448 			},
    449 			{
    450 				Variant: 0,
    451 			}: {
    452 				Hostname:          "portal.sso.{region}.cloud.adc-e.uk",
    453 				Protocols:         []string{"https"},
    454 				SignatureVersions: []string{"v4"},
    455 			},
    456 		},
    457 		RegionRegex:    partitionRegexp.AwsIsoE,
    458 		IsRegionalized: true,
    459 	},
    460 	{
    461 		ID: "aws-iso-f",
    462 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    463 			{
    464 				Variant: endpoints.FIPSVariant,
    465 			}: {
    466 				Hostname:          "portal.sso-fips.{region}.csp.hci.ic.gov",
    467 				Protocols:         []string{"https"},
    468 				SignatureVersions: []string{"v4"},
    469 			},
    470 			{
    471 				Variant: 0,
    472 			}: {
    473 				Hostname:          "portal.sso.{region}.csp.hci.ic.gov",
    474 				Protocols:         []string{"https"},
    475 				SignatureVersions: []string{"v4"},
    476 			},
    477 		},
    478 		RegionRegex:    partitionRegexp.AwsIsoF,
    479 		IsRegionalized: true,
    480 	},
    481 	{
    482 		ID: "aws-us-gov",
    483 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    484 			{
    485 				Variant: endpoints.DualStackVariant,
    486 			}: {
    487 				Hostname:          "portal.sso.{region}.api.aws",
    488 				Protocols:         []string{"https"},
    489 				SignatureVersions: []string{"v4"},
    490 			},
    491 			{
    492 				Variant: endpoints.FIPSVariant,
    493 			}: {
    494 				Hostname:          "portal.sso-fips.{region}.amazonaws.com",
    495 				Protocols:         []string{"https"},
    496 				SignatureVersions: []string{"v4"},
    497 			},
    498 			{
    499 				Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
    500 			}: {
    501 				Hostname:          "portal.sso-fips.{region}.api.aws",
    502 				Protocols:         []string{"https"},
    503 				SignatureVersions: []string{"v4"},
    504 			},
    505 			{
    506 				Variant: 0,
    507 			}: {
    508 				Hostname:          "portal.sso.{region}.amazonaws.com",
    509 				Protocols:         []string{"https"},
    510 				SignatureVersions: []string{"v4"},
    511 			},
    512 		},
    513 		RegionRegex:    partitionRegexp.AwsUsGov,
    514 		IsRegionalized: true,
    515 		Endpoints: endpoints.Endpoints{
    516 			endpoints.EndpointKey{
    517 				Region: "us-gov-east-1",
    518 			}: endpoints.Endpoint{
    519 				Hostname: "portal.sso.us-gov-east-1.amazonaws.com",
    520 				CredentialScope: endpoints.CredentialScope{
    521 					Region: "us-gov-east-1",
    522 				},
    523 			},
    524 			endpoints.EndpointKey{
    525 				Region: "us-gov-west-1",
    526 			}: endpoints.Endpoint{
    527 				Hostname: "portal.sso.us-gov-west-1.amazonaws.com",
    528 				CredentialScope: endpoints.CredentialScope{
    529 					Region: "us-gov-west-1",
    530 				},
    531 			},
    532 		},
    533 	},
    534 }