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 55bebfb
Showing 1 changed file with 5 additions and 1 deletion.
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 @@ -710,6 +710,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 55bebfb

Please sign in to comment.