Skip to content

Commit 7aef957

Browse files
author
Niko Lehtovirta
authored
fix: Fetch all api gateways (#15)
Earlier implementation did not take pagination into consideration. With this fix all of the api gateways are fetched
1 parent 17ba575 commit 7aef957

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/lib/aws-sdk/api_gateway.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@ export async function getRoutes(include: string[], exclude: string[]): Promise<A
77
validateCredentials();
88

99
const gateway = new AWS.APIGateway();
10+
const apis: AWS.APIGateway.ListOfRestApi = [];
1011

1112
debug('Getting api gateway routes');
12-
const res = await gateway.getRestApis().promise();
13-
debug('All api gateway routes count:', res?.items?.length || 0);
14-
return (res?.items || []).filter(r => match(r.name || '', include, exclude));
13+
let position: string | undefined;
14+
do {
15+
debug('Getting rest apis...');
16+
const res = await gateway.getRestApis({ position }).promise();
17+
apis.push(...(res.items || []));
18+
position = res.position;
19+
} while (position);
20+
21+
debug('All rest apis count:', apis?.length || 0);
22+
return apis.filter(r => match(r.name || '', include, exclude));
1523
}

0 commit comments

Comments
 (0)