From 792f3c6d12fb518f412e614ca3aebe9fc9e953f2 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Wed, 30 Aug 2023 08:57:58 -0700 Subject: [PATCH] ci: fix cleanup script - stale stack detection (#13167) * fix: include missing regions * chore: add debug output * fix: stale filter * Revert "chore: add debug output" This reverts commit 66c7ee7d0d64a9a2c6f2c72af3209a8c0f929211. * fix: stale filter --- .../amplify-e2e-tests/src/cleanup-codebuild-resources.ts | 7 +++++-- packages/amplify-e2e-tests/src/cleanup-e2e-resources.ts | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/amplify-e2e-tests/src/cleanup-codebuild-resources.ts b/packages/amplify-e2e-tests/src/cleanup-codebuild-resources.ts index 1fa65980c8d..83bea6f5b16 100644 --- a/packages/amplify-e2e-tests/src/cleanup-codebuild-resources.ts +++ b/packages/amplify-e2e-tests/src/cleanup-codebuild-resources.ts @@ -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', ]; @@ -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, diff --git a/packages/amplify-e2e-tests/src/cleanup-e2e-resources.ts b/packages/amplify-e2e-tests/src/cleanup-e2e-resources.ts index 00260440ae4..9f3de3a415c 100644 --- a/packages/amplify-e2e-tests/src/cleanup-e2e-resources.ts +++ b/packages/amplify-e2e-tests/src/cleanup-e2e-resources.ts @@ -398,10 +398,11 @@ const getStacks = async (account: AWSAccountInfo, region: string): Promise { 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,