@@ -14,24 +14,35 @@ const commandName = `cleanup`;
1414
1515const 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