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