Skip to content

Commit 82ab1ce

Browse files
authored
fix(resourcemapping): added compare and next token for list stack (#1248)
1 parent cd011af commit 82ab1ce

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

reference-artifacts/Custom-Scripts/lza-upgrade/src/resource-mapping.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -666,22 +666,27 @@ export class ResourceMapping {
666666

667667
async getStackList(cloudformation: CloudFormation, environment: Environment) {
668668
const stacks: string[] = [];
669-
const response = await cloudformation
670-
.listStacks({
671-
StackStatusFilter: [
672-
'CREATE_COMPLETE',
673-
'UPDATE_COMPLETE',
674-
'UPDATE_ROLLBACK_FAILED',
675-
'UPDATE_ROLLBACK_COMPLETE',
676-
'IMPORT_COMPLETE',
677-
],
678-
})
679-
.promise();
680-
for (const stackSummary of response.StackSummaries || []) {
681-
if (stackSummary.StackName.includes('Phase')) {
682-
stacks.push(stackSummary.StackName);
669+
let nextToken: string | undefined;
670+
do {
671+
const response = await cloudformation
672+
.listStacks({
673+
NextToken: nextToken,
674+
StackStatusFilter: [
675+
'CREATE_COMPLETE',
676+
'UPDATE_COMPLETE',
677+
'UPDATE_ROLLBACK_FAILED',
678+
'UPDATE_ROLLBACK_COMPLETE',
679+
'IMPORT_COMPLETE',
680+
],
681+
})
682+
.promise();
683+
for (const stackSummary of response.StackSummaries || []) {
684+
if (stackSummary.StackName.includes('Phase')) {
685+
stacks.push(stackSummary.StackName);
686+
}
683687
}
684-
}
688+
nextToken = response.NextToken;
689+
} while (nextToken);
685690
return {
686691
stacks,
687692
environment,

0 commit comments

Comments
 (0)