From 282b7bbee9f14774d4826276c1e2bb2d950478cd Mon Sep 17 00:00:00 2001 From: kostya-shramenko Date: Thu, 12 Mar 2026 14:00:05 +0100 Subject: [PATCH 1/2] fix: remove hosted zone name from cleanup command --- src/cleanup-command.ts | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/cleanup-command.ts b/src/cleanup-command.ts index a0f70eb..a6d485f 100644 --- a/src/cleanup-command.ts +++ b/src/cleanup-command.ts @@ -14,35 +14,24 @@ const commandName = `cleanup`; const region = process.env[`AWS_REGION`] || process.env[`AWS_DEFAULT_REGION`]; -export const cleanupCommand: CommandModule< - {}, - { readonly yes: boolean; readonly hostedZoneName?: string } -> = { +export const cleanupCommand: CommandModule<{}, { readonly yes: boolean }> = { command: `${commandName} [options]`, describe: `Deletes unused resources created by aws-simple for same region using new default region tag. If resource does not contain this tag, it will be deleted even if other regions are using it.`, builder: (argv) => argv - .options(`hosted-zone-name`, { - describe: `An optional hosted zone name to filter stacks`, - string: true, - }) .options(`yes`, { describe: `Confirm the deletion of unused resources for region: ${region}`, boolean: true, default: false, }) - .example([ - [`npx $0 ${commandName}`], - [`npx $0 ${commandName} --hosted-zone-name example.com`], - [`npx $0 ${commandName} --yes`], - ]), + .example([[`npx $0 ${commandName}`], [`npx $0 ${commandName} --yes`]]), handler: async (args): Promise => { print.info(`Searching unused resources for region ${region}...`); - const stacks = await findStacks(args.hostedZoneName); + const stacks = await findStacks(); const allResourceIds = new Set(); for (const stack of stacks) { From 77f063229e39ff53de6ff2a0fd2dcb84cc0d642d Mon Sep 17 00:00:00 2001 From: kostya-shramenko Date: Thu, 12 Mar 2026 16:57:52 +0100 Subject: [PATCH 2/2] fix: add comment why we are removing hosted zone filtering --- src/cleanup-command.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cleanup-command.ts b/src/cleanup-command.ts index a6d485f..31195e3 100644 --- a/src/cleanup-command.ts +++ b/src/cleanup-command.ts @@ -31,6 +31,10 @@ export const cleanupCommand: CommandModule<{}, { readonly yes: boolean }> = { handler: async (args): Promise => { print.info(`Searching unused resources for region ${region}...`); + // All stacks must be fetched without filtering (e.g. by hosted zone name) + // because the role cleanup below is account-wide. Fetching only a subset of + // stacks would cause roles from excluded stacks to be misidentified as + // unused and deleted const stacks = await findStacks(); const allResourceIds = new Set();