From 8ae41d606b4c7db3d3cdaee3504588fbec289ab1 Mon Sep 17 00:00:00 2001 From: Oluwatoni Solarin-Sodara Date: Tue, 20 Feb 2018 15:47:46 +0100 Subject: [PATCH 1/5] update circleci config to run aws-nuke nightly --- circle.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/circle.yml b/circle.yml index ccf76deb..2484ee0b 100644 --- a/circle.yml +++ b/circle.yml @@ -42,6 +42,14 @@ jobs: root: . paths: bin + run: + <<: *defaults + steps: + - checkout + - attach_workspace: + at: /go/src/github.com/gruntwork-io/aws-nuke + - run: go run main.go + deploy: <<: *defaults steps: @@ -70,7 +78,12 @@ workflows: filters: tags: only: /^v.*/ - + - run: + requires: + - test + filters: + tags: + only: /^v.*/ - deploy: requires: - build @@ -92,4 +105,7 @@ workflows: - install_dependencies - test: requires: - - install_dependencies \ No newline at end of file + - install_dependencies + - run: + requires: + - test \ No newline at end of file From 3329aa2459390997f8e9c394064a0b9d58918160 Mon Sep 17 00:00:00 2001 From: Oluwatoni Solarin-Sodara Date: Tue, 20 Feb 2018 19:36:26 +0100 Subject: [PATCH 2/5] update aws-nuke run arguments and job name --- circle.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/circle.yml b/circle.yml index 2484ee0b..e71997e2 100644 --- a/circle.yml +++ b/circle.yml @@ -42,13 +42,13 @@ jobs: root: . paths: bin - run: + nuke_phx_devops: <<: *defaults steps: - checkout - attach_workspace: at: /go/src/github.com/gruntwork-io/aws-nuke - - run: go run main.go + - run: go run main.go --older-than 48h --exclude-region us-west-2 deploy: <<: *defaults @@ -78,12 +78,9 @@ workflows: filters: tags: only: /^v.*/ - - run: + - nuke_phx_devops: requires: - test - filters: - tags: - only: /^v.*/ - deploy: requires: - build @@ -106,6 +103,6 @@ workflows: - test: requires: - install_dependencies - - run: + - nuke_phx_devops: requires: - test \ No newline at end of file From 8ba92d1ca932a2fd571214abe15cb8ff542a3850 Mon Sep 17 00:00:00 2001 From: Oluwatoni Solarin-Sodara Date: Wed, 21 Feb 2018 10:04:54 +0100 Subject: [PATCH 3/5] only run nuke_phx_devops nightly --- circle.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/circle.yml b/circle.yml index e71997e2..da67970c 100644 --- a/circle.yml +++ b/circle.yml @@ -78,9 +78,6 @@ workflows: filters: tags: only: /^v.*/ - - nuke_phx_devops: - requires: - - test - deploy: requires: - build From 797b52b3448459d5545e47e02ed3768a5bdb5a22 Mon Sep 17 00:00:00 2001 From: Oluwatoni Solarin-Sodara Date: Wed, 21 Feb 2018 11:22:32 +0100 Subject: [PATCH 4/5] add force flag to aws-nuke to skip confirmation prompt --- circle.yml | 2 +- commands/cli.go | 32 ++++++++++++++++++++++---------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/circle.yml b/circle.yml index da67970c..a666b43c 100644 --- a/circle.yml +++ b/circle.yml @@ -48,7 +48,7 @@ jobs: - checkout - attach_workspace: at: /go/src/github.com/gruntwork-io/aws-nuke - - run: go run main.go --older-than 48h --exclude-region us-west-2 + - run: go run main.go --older-than 48h --exclude-region us-west-2 --force deploy: <<: *defaults diff --git a/commands/cli.go b/commands/cli.go index c1d8757f..9127ce08 100644 --- a/commands/cli.go +++ b/commands/cli.go @@ -33,6 +33,10 @@ func CreateCli(version string) *cli.App { Usage: "Only delete resources older than this specified value. Can be any valid Go duration, such as 10m or 8h.", Value: "0s", }, + cli.BoolFlag{ + Name: "force", + Usage: "Skip nuke confirmation prompt", + }, } app.Action = errors.WithPanicHandling(awsNuke) @@ -93,19 +97,27 @@ func awsNuke(c *cli.Context) error { } } - color := color.New(color.FgHiRed, color.Bold) - color.Println("\nTHE NEXT STEPS ARE DESTRUCTIVE AND COMPLETELY IRREVERSIBLE, PROCEED WITH CAUTION!!!") + if !c.Bool("force") { + color := color.New(color.FgHiRed, color.Bold) + color.Println("\nTHE NEXT STEPS ARE DESTRUCTIVE AND COMPLETELY IRREVERSIBLE, PROCEED WITH CAUTION!!!") - prompt := "\nAre you sure you want to nuke all listed resources? Enter 'nuke' to confirm: " - shellOptions := shell.ShellOptions{Logger: logging.Logger} - input, err := shell.PromptUserForInput(prompt, &shellOptions) + prompt := "\nAre you sure you want to nuke all listed resources? Enter 'nuke' to confirm: " + shellOptions := shell.ShellOptions{Logger: logging.Logger} + input, err := shell.PromptUserForInput(prompt, &shellOptions) - if err != nil { - return errors.WithStackTrace(err) - } + if err != nil { + return errors.WithStackTrace(err) + } - if strings.ToLower(input) == "nuke" { - aws.NukeAllResources(account, regions) + if strings.ToLower(input) == "nuke" { + if err := aws.NukeAllResources(account, regions); err != nil { + return err + } + } + } else { + if err := aws.NukeAllResources(account, regions); err != nil { + return err + } } return nil From ad74d1532b6d49c4ffbc0f5376d79eac64b96d41 Mon Sep 17 00:00:00 2001 From: Oluwatoni Solarin-Sodara Date: Wed, 21 Feb 2018 12:14:11 +0100 Subject: [PATCH 5/5] make the destructive usage of the force flag obvious --- commands/cli.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands/cli.go b/commands/cli.go index 9127ce08..39670374 100644 --- a/commands/cli.go +++ b/commands/cli.go @@ -35,7 +35,7 @@ func CreateCli(version string) *cli.App { }, cli.BoolFlag{ Name: "force", - Usage: "Skip nuke confirmation prompt", + Usage: "Skip nuke confirmation prompt. WARNING: this will automatically delete all resources without any confirmation", }, } @@ -115,6 +115,7 @@ func awsNuke(c *cli.Context) error { } } } else { + logging.Logger.Infoln("The --force flag is set, so proceeding without confirmation.") if err := aws.NukeAllResources(account, regions); err != nil { return err }