diff --git a/src/cleanup-command.ts b/src/cleanup-command.ts index a6d485f..a0f70eb 100644 --- a/src/cleanup-command.ts +++ b/src/cleanup-command.ts @@ -14,24 +14,35 @@ const commandName = `cleanup`; const region = process.env[`AWS_REGION`] || process.env[`AWS_DEFAULT_REGION`]; -export const cleanupCommand: CommandModule<{}, { readonly yes: boolean }> = { +export const cleanupCommand: CommandModule< + {}, + { readonly yes: boolean; readonly hostedZoneName?: string } +> = { 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} --yes`]]), + .example([ + [`npx $0 ${commandName}`], + [`npx $0 ${commandName} --hosted-zone-name example.com`], + [`npx $0 ${commandName} --yes`], + ]), handler: async (args): Promise => { print.info(`Searching unused resources for region ${region}...`); - const stacks = await findStacks(); + const stacks = await findStacks(args.hostedZoneName); const allResourceIds = new Set(); for (const stack of stacks) {