src

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

endpoints.go (13841B)


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