Skip to content

Commit 056a4e4

Browse files
authored
Merge pull request #186 from kostya-shramenko/feat/pass-hosted-zone-name-to-cleanup-command
feat: pass hosted zone name to cleanup command
2 parents f86c8e9 + 6433d90 commit 056a4e4

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/cleanup-command.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,35 @@ const commandName = `cleanup`;
1414

1515
const region = process.env[`AWS_REGION`] || process.env[`AWS_DEFAULT_REGION`];
1616

17-
export const cleanupCommand: CommandModule<{}, { readonly yes: boolean }> = {
17+
export const cleanupCommand: CommandModule<
18+
{},
19+
{ readonly yes: boolean; readonly hostedZoneName?: string }
20+
> = {
1821
command: `${commandName} [options]`,
1922
describe: `Deletes unused resources created by aws-simple for same region using new default region tag.
2023
If resource does not contain this tag, it will be deleted even if other regions are using it.`,
2124

2225
builder: (argv) =>
2326
argv
27+
.options(`hosted-zone-name`, {
28+
describe: `An optional hosted zone name to filter stacks`,
29+
string: true,
30+
})
2431
.options(`yes`, {
2532
describe: `Confirm the deletion of unused resources for region: ${region}`,
2633
boolean: true,
2734
default: false,
2835
})
29-
.example([[`npx $0 ${commandName}`], [`npx $0 ${commandName} --yes`]]),
36+
.example([
37+
[`npx $0 ${commandName}`],
38+
[`npx $0 ${commandName} --hosted-zone-name example.com`],
39+
[`npx $0 ${commandName} --yes`],
40+
]),
3041

3142
handler: async (args): Promise<void> => {
3243
print.info(`Searching unused resources for region ${region}...`);
3344

34-
const stacks = await findStacks();
45+
const stacks = await findStacks(args.hostedZoneName);
3546
const allResourceIds = new Set<string>();
3647

3748
for (const stack of stacks) {

0 commit comments

Comments
 (0)