src

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

endpoints.go (11850B)


      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 Route 53 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:          "route53.{region}.api.aws",
    116 				Protocols:         []string{"https"},
    117 				SignatureVersions: []string{"v4"},
    118 			},
    119 			{
    120 				Variant: endpoints.FIPSVariant,
    121 			}: {
    122 				Hostname:          "route53-fips.{region}.amazonaws.com",
    123 				Protocols:         []string{"https"},
    124 				SignatureVersions: []string{"v4"},
    125 			},
    126 			{
    127 				Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
    128 			}: {
    129 				Hostname:          "route53-fips.{region}.api.aws",
    130 				Protocols:         []string{"https"},
    131 				SignatureVersions: []string{"v4"},
    132 			},
    133 			{
    134 				Variant: 0,
    135 			}: {
    136 				Hostname:          "route53.{region}.amazonaws.com",
    137 				Protocols:         []string{"https"},
    138 				SignatureVersions: []string{"v4"},
    139 			},
    140 		},
    141 		RegionRegex:       partitionRegexp.Aws,
    142 		IsRegionalized:    false,
    143 		PartitionEndpoint: "aws-global",
    144 		Endpoints: endpoints.Endpoints{
    145 			endpoints.EndpointKey{
    146 				Region: "aws-global",
    147 			}: endpoints.Endpoint{
    148 				Hostname: "route53.amazonaws.com",
    149 				CredentialScope: endpoints.CredentialScope{
    150 					Region: "us-east-1",
    151 				},
    152 			},
    153 			endpoints.EndpointKey{
    154 				Region:  "aws-global",
    155 				Variant: endpoints.FIPSVariant,
    156 			}: {
    157 				Hostname: "route53-fips.amazonaws.com",
    158 				CredentialScope: endpoints.CredentialScope{
    159 					Region: "us-east-1",
    160 				},
    161 			},
    162 			endpoints.EndpointKey{
    163 				Region: "fips-aws-global",
    164 			}: endpoints.Endpoint{
    165 				Hostname: "route53-fips.amazonaws.com",
    166 				CredentialScope: endpoints.CredentialScope{
    167 					Region: "us-east-1",
    168 				},
    169 				Deprecated: aws.TrueTernary,
    170 			},
    171 		},
    172 	},
    173 	{
    174 		ID: "aws-cn",
    175 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    176 			{
    177 				Variant: endpoints.DualStackVariant,
    178 			}: {
    179 				Hostname:          "route53.{region}.api.amazonwebservices.com.cn",
    180 				Protocols:         []string{"https"},
    181 				SignatureVersions: []string{"v4"},
    182 			},
    183 			{
    184 				Variant: endpoints.FIPSVariant,
    185 			}: {
    186 				Hostname:          "route53-fips.{region}.amazonaws.com.cn",
    187 				Protocols:         []string{"https"},
    188 				SignatureVersions: []string{"v4"},
    189 			},
    190 			{
    191 				Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
    192 			}: {
    193 				Hostname:          "route53-fips.{region}.api.amazonwebservices.com.cn",
    194 				Protocols:         []string{"https"},
    195 				SignatureVersions: []string{"v4"},
    196 			},
    197 			{
    198 				Variant: 0,
    199 			}: {
    200 				Hostname:          "route53.{region}.amazonaws.com.cn",
    201 				Protocols:         []string{"https"},
    202 				SignatureVersions: []string{"v4"},
    203 			},
    204 		},
    205 		RegionRegex:       partitionRegexp.AwsCn,
    206 		IsRegionalized:    false,
    207 		PartitionEndpoint: "aws-cn-global",
    208 		Endpoints: endpoints.Endpoints{
    209 			endpoints.EndpointKey{
    210 				Region: "aws-cn-global",
    211 			}: endpoints.Endpoint{
    212 				Hostname: "route53.amazonaws.com.cn",
    213 				CredentialScope: endpoints.CredentialScope{
    214 					Region: "cn-northwest-1",
    215 				},
    216 			},
    217 		},
    218 	},
    219 	{
    220 		ID: "aws-eusc",
    221 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    222 			{
    223 				Variant: endpoints.FIPSVariant,
    224 			}: {
    225 				Hostname:          "route53-fips.{region}.amazonaws.eu",
    226 				Protocols:         []string{"https"},
    227 				SignatureVersions: []string{"v4"},
    228 			},
    229 			{
    230 				Variant: 0,
    231 			}: {
    232 				Hostname:          "route53.{region}.amazonaws.eu",
    233 				Protocols:         []string{"https"},
    234 				SignatureVersions: []string{"v4"},
    235 			},
    236 		},
    237 		RegionRegex:    partitionRegexp.AwsEusc,
    238 		IsRegionalized: true,
    239 	},
    240 	{
    241 		ID: "aws-iso",
    242 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    243 			{
    244 				Variant: endpoints.FIPSVariant,
    245 			}: {
    246 				Hostname:          "route53-fips.{region}.c2s.ic.gov",
    247 				Protocols:         []string{"https"},
    248 				SignatureVersions: []string{"v4"},
    249 			},
    250 			{
    251 				Variant: 0,
    252 			}: {
    253 				Hostname:          "route53.{region}.c2s.ic.gov",
    254 				Protocols:         []string{"https"},
    255 				SignatureVersions: []string{"v4"},
    256 			},
    257 		},
    258 		RegionRegex:       partitionRegexp.AwsIso,
    259 		IsRegionalized:    false,
    260 		PartitionEndpoint: "aws-iso-global",
    261 		Endpoints: endpoints.Endpoints{
    262 			endpoints.EndpointKey{
    263 				Region: "aws-iso-global",
    264 			}: endpoints.Endpoint{
    265 				Hostname: "route53.c2s.ic.gov",
    266 				CredentialScope: endpoints.CredentialScope{
    267 					Region: "us-iso-east-1",
    268 				},
    269 			},
    270 		},
    271 	},
    272 	{
    273 		ID: "aws-iso-b",
    274 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    275 			{
    276 				Variant: endpoints.FIPSVariant,
    277 			}: {
    278 				Hostname:          "route53-fips.{region}.sc2s.sgov.gov",
    279 				Protocols:         []string{"https"},
    280 				SignatureVersions: []string{"v4"},
    281 			},
    282 			{
    283 				Variant: 0,
    284 			}: {
    285 				Hostname:          "route53.{region}.sc2s.sgov.gov",
    286 				Protocols:         []string{"https"},
    287 				SignatureVersions: []string{"v4"},
    288 			},
    289 		},
    290 		RegionRegex:       partitionRegexp.AwsIsoB,
    291 		IsRegionalized:    false,
    292 		PartitionEndpoint: "aws-iso-b-global",
    293 		Endpoints: endpoints.Endpoints{
    294 			endpoints.EndpointKey{
    295 				Region: "aws-iso-b-global",
    296 			}: endpoints.Endpoint{
    297 				Hostname: "route53.sc2s.sgov.gov",
    298 				CredentialScope: endpoints.CredentialScope{
    299 					Region: "us-isob-east-1",
    300 				},
    301 			},
    302 		},
    303 	},
    304 	{
    305 		ID: "aws-iso-e",
    306 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    307 			{
    308 				Variant: endpoints.FIPSVariant,
    309 			}: {
    310 				Hostname:          "route53-fips.{region}.cloud.adc-e.uk",
    311 				Protocols:         []string{"https"},
    312 				SignatureVersions: []string{"v4"},
    313 			},
    314 			{
    315 				Variant: 0,
    316 			}: {
    317 				Hostname:          "route53.{region}.cloud.adc-e.uk",
    318 				Protocols:         []string{"https"},
    319 				SignatureVersions: []string{"v4"},
    320 			},
    321 		},
    322 		RegionRegex:       partitionRegexp.AwsIsoE,
    323 		IsRegionalized:    false,
    324 		PartitionEndpoint: "aws-iso-e-global",
    325 		Endpoints: endpoints.Endpoints{
    326 			endpoints.EndpointKey{
    327 				Region: "aws-iso-e-global",
    328 			}: endpoints.Endpoint{
    329 				Hostname: "route53.cloud.adc-e.uk",
    330 				CredentialScope: endpoints.CredentialScope{
    331 					Region: "eu-isoe-west-1",
    332 				},
    333 			},
    334 		},
    335 	},
    336 	{
    337 		ID: "aws-iso-f",
    338 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    339 			{
    340 				Variant: endpoints.FIPSVariant,
    341 			}: {
    342 				Hostname:          "route53-fips.{region}.csp.hci.ic.gov",
    343 				Protocols:         []string{"https"},
    344 				SignatureVersions: []string{"v4"},
    345 			},
    346 			{
    347 				Variant: 0,
    348 			}: {
    349 				Hostname:          "route53.{region}.csp.hci.ic.gov",
    350 				Protocols:         []string{"https"},
    351 				SignatureVersions: []string{"v4"},
    352 			},
    353 		},
    354 		RegionRegex:       partitionRegexp.AwsIsoF,
    355 		IsRegionalized:    false,
    356 		PartitionEndpoint: "aws-iso-f-global",
    357 		Endpoints: endpoints.Endpoints{
    358 			endpoints.EndpointKey{
    359 				Region: "aws-iso-f-global",
    360 			}: endpoints.Endpoint{
    361 				Hostname: "route53.csp.hci.ic.gov",
    362 				CredentialScope: endpoints.CredentialScope{
    363 					Region: "us-isof-south-1",
    364 				},
    365 			},
    366 		},
    367 	},
    368 	{
    369 		ID: "aws-us-gov",
    370 		Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
    371 			{
    372 				Variant: endpoints.DualStackVariant,
    373 			}: {
    374 				Hostname:          "route53.{region}.api.aws",
    375 				Protocols:         []string{"https"},
    376 				SignatureVersions: []string{"v4"},
    377 			},
    378 			{
    379 				Variant: endpoints.FIPSVariant,
    380 			}: {
    381 				Hostname:          "route53-fips.{region}.amazonaws.com",
    382 				Protocols:         []string{"https"},
    383 				SignatureVersions: []string{"v4"},
    384 			},
    385 			{
    386 				Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
    387 			}: {
    388 				Hostname:          "route53-fips.{region}.api.aws",
    389 				Protocols:         []string{"https"},
    390 				SignatureVersions: []string{"v4"},
    391 			},
    392 			{
    393 				Variant: 0,
    394 			}: {
    395 				Hostname:          "route53.{region}.amazonaws.com",
    396 				Protocols:         []string{"https"},
    397 				SignatureVersions: []string{"v4"},
    398 			},
    399 		},
    400 		RegionRegex:       partitionRegexp.AwsUsGov,
    401 		IsRegionalized:    false,
    402 		PartitionEndpoint: "aws-us-gov-global",
    403 		Endpoints: endpoints.Endpoints{
    404 			endpoints.EndpointKey{
    405 				Region: "aws-us-gov-global",
    406 			}: endpoints.Endpoint{
    407 				Hostname: "route53.us-gov.amazonaws.com",
    408 				CredentialScope: endpoints.CredentialScope{
    409 					Region: "us-gov-west-1",
    410 				},
    411 			},
    412 			endpoints.EndpointKey{
    413 				Region:  "aws-us-gov-global",
    414 				Variant: endpoints.FIPSVariant,
    415 			}: {
    416 				Hostname: "route53.us-gov.amazonaws.com",
    417 				CredentialScope: endpoints.CredentialScope{
    418 					Region: "us-gov-west-1",
    419 				},
    420 			},
    421 			endpoints.EndpointKey{
    422 				Region: "fips-aws-us-gov-global",
    423 			}: endpoints.Endpoint{
    424 				Hostname: "route53.us-gov.amazonaws.com",
    425 				CredentialScope: endpoints.CredentialScope{
    426 					Region: "us-gov-west-1",
    427 				},
    428 				Deprecated: aws.TrueTernary,
    429 			},
    430 		},
    431 	},
    432 }