From 9f643f03f12a22a3e103dc2b667d6f49330d4a77 Mon Sep 17 00:00:00 2001 From: Cristian Goina Date: Tue, 16 Aug 2022 09:36:14 -0400 Subject: [PATCH] options to not remove image --- scripts/destroy.js | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/scripts/destroy.js b/scripts/destroy.js index 1aee724..3ad80fe 100644 --- a/scripts/destroy.js +++ b/scripts/destroy.js @@ -52,10 +52,12 @@ function destroy(argv) { cwd: "./admin_api_stack/", }); - console.log(chalk.yellow("⚠️ Removing Workstation stack")); - exec(`npm run cdk -- destroy -f --require-approval never Workstation`, { - cwd: "./workstation_stack/", - }); + if (!argv.keepWorkstation) { + console.log(chalk.yellow("⚠️ Removing Workstation stack")); + exec(`npm run cdk -- destroy -f --require-approval never Workstation`, { + cwd: "./workstation_stack/", + }); + } if (!argv.keepBackend) { console.log(chalk.yellow("⚠️ Removing VPC stack.")); @@ -65,6 +67,8 @@ function destroy(argv) { } if (argv.undeployCognito) { + // cognito has to be explicitly removed + // by default we keep it because we don't want to recreate users console.log(chalk.yellow("⚠️ Removing Cognito stack.")); exec( `npm run cdk -- destroy -f --all --require-approval never`, @@ -73,7 +77,12 @@ function destroy(argv) { } console.log(chalk.green("✅ All stacks have been removed.")); - removeAppStreamImage(); + if (!argv.keepHortaImage && !argv.keepWorkstation) { + // if we keep the workstation fleet + // the image cannot be removed anyway + // because it is still associated with the fleet + removeAppStreamImage(); + } } let missingVarsCount = 0; @@ -108,6 +117,14 @@ const argv = require("yargs/yargs")(process.argv.slice(2)) type: 'boolean', describe: 'If set keep the JACS stack' }) + .option('keep-workstation', { + type: 'boolean', + describe: 'Do not remove the workstation appstream stack and fleet.', + }) + .option('keep-horta-image', { + type: 'boolean', + describe: 'Do not remove Horta AppStream image', + }) .argv; (async () => {