Skip to content

Commit

Permalink
ci: fix cleanup script - stale stack detection (#13167)
Browse files Browse the repository at this point in the history
* fix: include missing regions

* chore: add debug output

* fix: stale filter

* Revert "chore: add debug output"

This reverts commit 66c7ee7.

* fix: stale filter
  • Loading branch information
sobolk committed Aug 30, 2023
1 parent 9703223 commit 792f3c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions packages/amplify-e2e-tests/src/cleanup-codebuild-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ const AWS_REGIONS_TO_RUN_TESTS = [
'us-east-2',
'us-west-2',
'eu-west-2',
'eu-west-3',
'eu-central-1',
'ap-northeast-1',
'ap-northeast-2',
'ap-southeast-1',
'ap-southeast-2',
];
Expand Down Expand Up @@ -471,10 +473,11 @@ const getStacks = async (account: AWSAccountInfo, region: string, cbClient: Code
// eventually, we must clean up those child stacks too.
let rootStacks = stacks.StackSummaries.filter((stack) => {
const isRoot = !stack.RootId;
if (!isStale(stack.CreationTime)) {
const isStackStale = isStale(stack.CreationTime);
if (!isStackStale) {
console.log('Skipping stack because created date is:', stack.CreationTime);
}
return isRoot && isStale;
return isRoot && isStackStale;
});
if (rootStacks.length > DELETE_LIMITS.PER_REGION.CFN_STACK) {
// we can only delete 100 stacks accross all regions every batch,
Expand Down
5 changes: 3 additions & 2 deletions packages/amplify-e2e-tests/src/cleanup-e2e-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,11 @@ const getStacks = async (account: AWSAccountInfo, region: string): Promise<Stack
// eventually, we must clean up those child stacks too.
let rootStacks = stacks.StackSummaries.filter((stack) => {
const isRoot = !stack.RootId;
if (!isStale(stack.CreationTime)) {
const isStackStale = isStale(stack.CreationTime);
if (!isStackStale) {
console.log('Skipping stack because created date is:', stack.CreationTime);
}
return isRoot && isStale;
return isRoot && isStackStale;
});
if (rootStacks.length > DELETE_LIMITS.PER_REGION.CFN_STACK) {
// we can only delete 100 stacks accross all regions every batch,
Expand Down

0 comments on commit 792f3c6

Please sign in to comment.