Skip to content

Commit

Permalink
feat(uninstallation): ignore accounts scheduled for closure
Browse files Browse the repository at this point in the history
  • Loading branch information
richardkeit committed Feb 21, 2025
1 parent 24896ff commit e703d00
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import {
KMSClient,
ScheduleKeyDeletionCommand,
} from '@aws-sdk/client-kms';
import { ListAccountsCommand, OrganizationsClient } from '@aws-sdk/client-organizations';
import { AccountStatus, ListAccountsCommand, OrganizationsClient } from '@aws-sdk/client-organizations';
import {
DeleteBucketCommand,
DeleteObjectsCommand,
Expand Down Expand Up @@ -364,7 +364,6 @@ export class AcceleratorTool {
const installerPipeline = await AcceleratorTool.getPipelineNameFromCloudFormationStack(installerStackName);
if (!installerPipeline.status) {
this.debugLog(`${installerPipeline.pipelineName}`, 'info');
this.logger.error(`${installerPipeline.pipelineName} doesn't exist, cannot continue`);
return false;
}
const getPipelineNameResponse = await throttlingBackOff(() =>
Expand Down Expand Up @@ -710,6 +709,10 @@ export class AcceleratorTool {
organizationsClient.send(new ListAccountsCommand({ NextToken: nextToken })),
);
for (const account of page.Accounts ?? []) {
if (account.Status == AccountStatus.SUSPENDED) {
this.logger.error(`Account ${account.Name} (${account.Email} is suspended, will not be cleaned up)`);
continue;
}
if (account.Id && account.Name) {
accountIds.push({ accountName: account.Name, accountId: account.Id });
}
Expand Down

0 comments on commit e703d00

Please sign in to comment.