endpoints.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. // Code generated by smithy-go-codegen DO NOT EDIT.
  2. package endpoints
  3. import (
  4. "github.com/aws/aws-sdk-go-v2/aws"
  5. endpoints "github.com/aws/aws-sdk-go-v2/internal/endpoints/v2"
  6. "github.com/aws/smithy-go/logging"
  7. "regexp"
  8. )
  9. // Options is the endpoint resolver configuration options
  10. type Options struct {
  11. // Logger is a logging implementation that log events should be sent to.
  12. Logger logging.Logger
  13. // LogDeprecated indicates that deprecated endpoints should be logged to the
  14. // provided logger.
  15. LogDeprecated bool
  16. // ResolvedRegion is used to override the region to be resolved, rather then the
  17. // using the value passed to the ResolveEndpoint method. This value is used by the
  18. // SDK to translate regions like fips-us-east-1 or us-east-1-fips to an alternative
  19. // name. You must not set this value directly in your application.
  20. ResolvedRegion string
  21. // DisableHTTPS informs the resolver to return an endpoint that does not use the
  22. // HTTPS scheme.
  23. DisableHTTPS bool
  24. // UseDualStackEndpoint specifies the resolver must resolve a dual-stack endpoint.
  25. UseDualStackEndpoint aws.DualStackEndpointState
  26. // UseFIPSEndpoint specifies the resolver must resolve a FIPS endpoint.
  27. UseFIPSEndpoint aws.FIPSEndpointState
  28. }
  29. func (o Options) GetResolvedRegion() string {
  30. return o.ResolvedRegion
  31. }
  32. func (o Options) GetDisableHTTPS() bool {
  33. return o.DisableHTTPS
  34. }
  35. func (o Options) GetUseDualStackEndpoint() aws.DualStackEndpointState {
  36. return o.UseDualStackEndpoint
  37. }
  38. func (o Options) GetUseFIPSEndpoint() aws.FIPSEndpointState {
  39. return o.UseFIPSEndpoint
  40. }
  41. func transformToSharedOptions(options Options) endpoints.Options {
  42. return endpoints.Options{
  43. Logger: options.Logger,
  44. LogDeprecated: options.LogDeprecated,
  45. ResolvedRegion: options.ResolvedRegion,
  46. DisableHTTPS: options.DisableHTTPS,
  47. UseDualStackEndpoint: options.UseDualStackEndpoint,
  48. UseFIPSEndpoint: options.UseFIPSEndpoint,
  49. }
  50. }
  51. // Resolver SSO OIDC endpoint resolver
  52. type Resolver struct {
  53. partitions endpoints.Partitions
  54. }
  55. // ResolveEndpoint resolves the service endpoint for the given region and options
  56. func (r *Resolver) ResolveEndpoint(region string, options Options) (endpoint aws.Endpoint, err error) {
  57. if len(region) == 0 {
  58. return endpoint, &aws.MissingRegionError{}
  59. }
  60. opt := transformToSharedOptions(options)
  61. return r.partitions.ResolveEndpoint(region, opt)
  62. }
  63. // New returns a new Resolver
  64. func New() *Resolver {
  65. return &Resolver{
  66. partitions: defaultPartitions,
  67. }
  68. }
  69. var partitionRegexp = struct {
  70. Aws *regexp.Regexp
  71. AwsCn *regexp.Regexp
  72. AwsIso *regexp.Regexp
  73. AwsIsoB *regexp.Regexp
  74. AwsUsGov *regexp.Regexp
  75. }{
  76. Aws: regexp.MustCompile("^(us|eu|ap|sa|ca|me|af)\\-\\w+\\-\\d+$"),
  77. AwsCn: regexp.MustCompile("^cn\\-\\w+\\-\\d+$"),
  78. AwsIso: regexp.MustCompile("^us\\-iso\\-\\w+\\-\\d+$"),
  79. AwsIsoB: regexp.MustCompile("^us\\-isob\\-\\w+\\-\\d+$"),
  80. AwsUsGov: regexp.MustCompile("^us\\-gov\\-\\w+\\-\\d+$"),
  81. }
  82. var defaultPartitions = endpoints.Partitions{
  83. {
  84. ID: "aws",
  85. Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
  86. {
  87. Variant: endpoints.DualStackVariant,
  88. }: {
  89. Hostname: "oidc.{region}.api.aws",
  90. Protocols: []string{"https"},
  91. SignatureVersions: []string{"v4"},
  92. },
  93. {
  94. Variant: endpoints.FIPSVariant,
  95. }: {
  96. Hostname: "oidc-fips.{region}.amazonaws.com",
  97. Protocols: []string{"https"},
  98. SignatureVersions: []string{"v4"},
  99. },
  100. {
  101. Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
  102. }: {
  103. Hostname: "oidc-fips.{region}.api.aws",
  104. Protocols: []string{"https"},
  105. SignatureVersions: []string{"v4"},
  106. },
  107. {
  108. Variant: 0,
  109. }: {
  110. Hostname: "oidc.{region}.amazonaws.com",
  111. Protocols: []string{"https"},
  112. SignatureVersions: []string{"v4"},
  113. },
  114. },
  115. RegionRegex: partitionRegexp.Aws,
  116. IsRegionalized: true,
  117. Endpoints: endpoints.Endpoints{
  118. endpoints.EndpointKey{
  119. Region: "af-south-1",
  120. }: endpoints.Endpoint{
  121. Hostname: "oidc.af-south-1.amazonaws.com",
  122. CredentialScope: endpoints.CredentialScope{
  123. Region: "af-south-1",
  124. },
  125. },
  126. endpoints.EndpointKey{
  127. Region: "ap-east-1",
  128. }: endpoints.Endpoint{
  129. Hostname: "oidc.ap-east-1.amazonaws.com",
  130. CredentialScope: endpoints.CredentialScope{
  131. Region: "ap-east-1",
  132. },
  133. },
  134. endpoints.EndpointKey{
  135. Region: "ap-northeast-1",
  136. }: endpoints.Endpoint{
  137. Hostname: "oidc.ap-northeast-1.amazonaws.com",
  138. CredentialScope: endpoints.CredentialScope{
  139. Region: "ap-northeast-1",
  140. },
  141. },
  142. endpoints.EndpointKey{
  143. Region: "ap-northeast-2",
  144. }: endpoints.Endpoint{
  145. Hostname: "oidc.ap-northeast-2.amazonaws.com",
  146. CredentialScope: endpoints.CredentialScope{
  147. Region: "ap-northeast-2",
  148. },
  149. },
  150. endpoints.EndpointKey{
  151. Region: "ap-northeast-3",
  152. }: endpoints.Endpoint{
  153. Hostname: "oidc.ap-northeast-3.amazonaws.com",
  154. CredentialScope: endpoints.CredentialScope{
  155. Region: "ap-northeast-3",
  156. },
  157. },
  158. endpoints.EndpointKey{
  159. Region: "ap-south-1",
  160. }: endpoints.Endpoint{
  161. Hostname: "oidc.ap-south-1.amazonaws.com",
  162. CredentialScope: endpoints.CredentialScope{
  163. Region: "ap-south-1",
  164. },
  165. },
  166. endpoints.EndpointKey{
  167. Region: "ap-southeast-1",
  168. }: endpoints.Endpoint{
  169. Hostname: "oidc.ap-southeast-1.amazonaws.com",
  170. CredentialScope: endpoints.CredentialScope{
  171. Region: "ap-southeast-1",
  172. },
  173. },
  174. endpoints.EndpointKey{
  175. Region: "ap-southeast-2",
  176. }: endpoints.Endpoint{
  177. Hostname: "oidc.ap-southeast-2.amazonaws.com",
  178. CredentialScope: endpoints.CredentialScope{
  179. Region: "ap-southeast-2",
  180. },
  181. },
  182. endpoints.EndpointKey{
  183. Region: "ap-southeast-3",
  184. }: endpoints.Endpoint{
  185. Hostname: "oidc.ap-southeast-3.amazonaws.com",
  186. CredentialScope: endpoints.CredentialScope{
  187. Region: "ap-southeast-3",
  188. },
  189. },
  190. endpoints.EndpointKey{
  191. Region: "ca-central-1",
  192. }: endpoints.Endpoint{
  193. Hostname: "oidc.ca-central-1.amazonaws.com",
  194. CredentialScope: endpoints.CredentialScope{
  195. Region: "ca-central-1",
  196. },
  197. },
  198. endpoints.EndpointKey{
  199. Region: "eu-central-1",
  200. }: endpoints.Endpoint{
  201. Hostname: "oidc.eu-central-1.amazonaws.com",
  202. CredentialScope: endpoints.CredentialScope{
  203. Region: "eu-central-1",
  204. },
  205. },
  206. endpoints.EndpointKey{
  207. Region: "eu-north-1",
  208. }: endpoints.Endpoint{
  209. Hostname: "oidc.eu-north-1.amazonaws.com",
  210. CredentialScope: endpoints.CredentialScope{
  211. Region: "eu-north-1",
  212. },
  213. },
  214. endpoints.EndpointKey{
  215. Region: "eu-south-1",
  216. }: endpoints.Endpoint{
  217. Hostname: "oidc.eu-south-1.amazonaws.com",
  218. CredentialScope: endpoints.CredentialScope{
  219. Region: "eu-south-1",
  220. },
  221. },
  222. endpoints.EndpointKey{
  223. Region: "eu-west-1",
  224. }: endpoints.Endpoint{
  225. Hostname: "oidc.eu-west-1.amazonaws.com",
  226. CredentialScope: endpoints.CredentialScope{
  227. Region: "eu-west-1",
  228. },
  229. },
  230. endpoints.EndpointKey{
  231. Region: "eu-west-2",
  232. }: endpoints.Endpoint{
  233. Hostname: "oidc.eu-west-2.amazonaws.com",
  234. CredentialScope: endpoints.CredentialScope{
  235. Region: "eu-west-2",
  236. },
  237. },
  238. endpoints.EndpointKey{
  239. Region: "eu-west-3",
  240. }: endpoints.Endpoint{
  241. Hostname: "oidc.eu-west-3.amazonaws.com",
  242. CredentialScope: endpoints.CredentialScope{
  243. Region: "eu-west-3",
  244. },
  245. },
  246. endpoints.EndpointKey{
  247. Region: "me-south-1",
  248. }: endpoints.Endpoint{
  249. Hostname: "oidc.me-south-1.amazonaws.com",
  250. CredentialScope: endpoints.CredentialScope{
  251. Region: "me-south-1",
  252. },
  253. },
  254. endpoints.EndpointKey{
  255. Region: "sa-east-1",
  256. }: endpoints.Endpoint{
  257. Hostname: "oidc.sa-east-1.amazonaws.com",
  258. CredentialScope: endpoints.CredentialScope{
  259. Region: "sa-east-1",
  260. },
  261. },
  262. endpoints.EndpointKey{
  263. Region: "us-east-1",
  264. }: endpoints.Endpoint{
  265. Hostname: "oidc.us-east-1.amazonaws.com",
  266. CredentialScope: endpoints.CredentialScope{
  267. Region: "us-east-1",
  268. },
  269. },
  270. endpoints.EndpointKey{
  271. Region: "us-east-2",
  272. }: endpoints.Endpoint{
  273. Hostname: "oidc.us-east-2.amazonaws.com",
  274. CredentialScope: endpoints.CredentialScope{
  275. Region: "us-east-2",
  276. },
  277. },
  278. endpoints.EndpointKey{
  279. Region: "us-west-1",
  280. }: endpoints.Endpoint{
  281. Hostname: "oidc.us-west-1.amazonaws.com",
  282. CredentialScope: endpoints.CredentialScope{
  283. Region: "us-west-1",
  284. },
  285. },
  286. endpoints.EndpointKey{
  287. Region: "us-west-2",
  288. }: endpoints.Endpoint{
  289. Hostname: "oidc.us-west-2.amazonaws.com",
  290. CredentialScope: endpoints.CredentialScope{
  291. Region: "us-west-2",
  292. },
  293. },
  294. },
  295. },
  296. {
  297. ID: "aws-cn",
  298. Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
  299. {
  300. Variant: endpoints.DualStackVariant,
  301. }: {
  302. Hostname: "oidc.{region}.api.amazonwebservices.com.cn",
  303. Protocols: []string{"https"},
  304. SignatureVersions: []string{"v4"},
  305. },
  306. {
  307. Variant: endpoints.FIPSVariant,
  308. }: {
  309. Hostname: "oidc-fips.{region}.amazonaws.com.cn",
  310. Protocols: []string{"https"},
  311. SignatureVersions: []string{"v4"},
  312. },
  313. {
  314. Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
  315. }: {
  316. Hostname: "oidc-fips.{region}.api.amazonwebservices.com.cn",
  317. Protocols: []string{"https"},
  318. SignatureVersions: []string{"v4"},
  319. },
  320. {
  321. Variant: 0,
  322. }: {
  323. Hostname: "oidc.{region}.amazonaws.com.cn",
  324. Protocols: []string{"https"},
  325. SignatureVersions: []string{"v4"},
  326. },
  327. },
  328. RegionRegex: partitionRegexp.AwsCn,
  329. IsRegionalized: true,
  330. },
  331. {
  332. ID: "aws-iso",
  333. Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
  334. {
  335. Variant: endpoints.FIPSVariant,
  336. }: {
  337. Hostname: "oidc-fips.{region}.c2s.ic.gov",
  338. Protocols: []string{"https"},
  339. SignatureVersions: []string{"v4"},
  340. },
  341. {
  342. Variant: 0,
  343. }: {
  344. Hostname: "oidc.{region}.c2s.ic.gov",
  345. Protocols: []string{"https"},
  346. SignatureVersions: []string{"v4"},
  347. },
  348. },
  349. RegionRegex: partitionRegexp.AwsIso,
  350. IsRegionalized: true,
  351. },
  352. {
  353. ID: "aws-iso-b",
  354. Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
  355. {
  356. Variant: endpoints.FIPSVariant,
  357. }: {
  358. Hostname: "oidc-fips.{region}.sc2s.sgov.gov",
  359. Protocols: []string{"https"},
  360. SignatureVersions: []string{"v4"},
  361. },
  362. {
  363. Variant: 0,
  364. }: {
  365. Hostname: "oidc.{region}.sc2s.sgov.gov",
  366. Protocols: []string{"https"},
  367. SignatureVersions: []string{"v4"},
  368. },
  369. },
  370. RegionRegex: partitionRegexp.AwsIsoB,
  371. IsRegionalized: true,
  372. },
  373. {
  374. ID: "aws-us-gov",
  375. Defaults: map[endpoints.DefaultKey]endpoints.Endpoint{
  376. {
  377. Variant: endpoints.DualStackVariant,
  378. }: {
  379. Hostname: "oidc.{region}.api.aws",
  380. Protocols: []string{"https"},
  381. SignatureVersions: []string{"v4"},
  382. },
  383. {
  384. Variant: endpoints.FIPSVariant,
  385. }: {
  386. Hostname: "oidc-fips.{region}.amazonaws.com",
  387. Protocols: []string{"https"},
  388. SignatureVersions: []string{"v4"},
  389. },
  390. {
  391. Variant: endpoints.FIPSVariant | endpoints.DualStackVariant,
  392. }: {
  393. Hostname: "oidc-fips.{region}.api.aws",
  394. Protocols: []string{"https"},
  395. SignatureVersions: []string{"v4"},
  396. },
  397. {
  398. Variant: 0,
  399. }: {
  400. Hostname: "oidc.{region}.amazonaws.com",
  401. Protocols: []string{"https"},
  402. SignatureVersions: []string{"v4"},
  403. },
  404. },
  405. RegionRegex: partitionRegexp.AwsUsGov,
  406. IsRegionalized: true,
  407. Endpoints: endpoints.Endpoints{
  408. endpoints.EndpointKey{
  409. Region: "us-gov-east-1",
  410. }: endpoints.Endpoint{
  411. Hostname: "oidc.us-gov-east-1.amazonaws.com",
  412. CredentialScope: endpoints.CredentialScope{
  413. Region: "us-gov-east-1",
  414. },
  415. },
  416. endpoints.EndpointKey{
  417. Region: "us-gov-west-1",
  418. }: endpoints.Endpoint{
  419. Hostname: "oidc.us-gov-west-1.amazonaws.com",
  420. CredentialScope: endpoints.CredentialScope{
  421. Region: "us-gov-west-1",
  422. },
  423. },
  424. },
  425. },
  426. }