Skip to content

Commit 7c57128

Browse files
authored
fix(regions): prefer remote source over local source (#3085)
## Problem `endpointsProvider.ts` is not using the remote endpoints file ## Solution Rearrange the logic and add a test #### Notes * `endpointsProvider.ts` is still flawed in that it never caches the remote manifest. This PR is not a complete solution. * We should consider replacing our custom endpoints solution with public parameters: https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-public-parameters-global-infrastructure.html
1 parent 69f5fda commit 7c57128

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "AWS regions are not dynamically fetched by the Toolkit"
4+
}

src/shared/regions/endpointsProvider.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ export class EndpointsProvider {
2121

2222
public async load(): Promise<Endpoints> {
2323
getLogger().info('Retrieving AWS endpoint data')
24-
const localEndpointsJson = await this.localFetcher.get()
25-
if (localEndpointsJson) {
26-
const localEndpoints = loadEndpoints(localEndpointsJson)
27-
if (localEndpoints) {
28-
return localEndpoints
29-
}
30-
}
31-
3224
const remoteEndpointsJson = await this.remoteFetcher.get()
3325
if (remoteEndpointsJson) {
3426
const remoteEndpoints = loadEndpoints(remoteEndpointsJson)
@@ -37,6 +29,14 @@ export class EndpointsProvider {
3729
}
3830
}
3931

32+
const localEndpointsJson = await this.localFetcher.get()
33+
if (localEndpointsJson) {
34+
const localEndpoints = loadEndpoints(localEndpointsJson)
35+
if (localEndpoints) {
36+
return localEndpoints
37+
}
38+
}
39+
4040
// If endpoints were never loaded by this point, we have a critical error
4141
throw new Error('Failure to load any endpoints manifest data')
4242
}

src/test/shared/regions/endpointsProvider.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,11 @@ describe('EndpointsProvider', async function () {
4343

4444
assert.strictEqual(endpoints.partitions.length, 1)
4545
})
46+
47+
it('prefers remote fetcher over local fetcher', async function () {
48+
const provider = new EndpointsProvider(fetcher1, fetcher2)
49+
const endpoints = await provider.load()
50+
51+
assert.strictEqual(endpoints.partitions.length, 1)
52+
})
4653
})

0 commit comments

Comments
 (0)