Skip to content

Commit

Permalink
Merge pull request #12 from gruntwork-io/nightly-run
Browse files Browse the repository at this point in the history
update circleci config to run aws-nuke nightly
  • Loading branch information
brikis98 authored Feb 21, 2018
2 parents d7231e3 + ad74d15 commit 01ca5be
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
14 changes: 12 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ jobs:
root: .
paths: bin

nuke_phx_devops:
<<: *defaults
steps:
- 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 --force

deploy:
<<: *defaults
steps:
Expand Down Expand Up @@ -70,7 +78,6 @@ workflows:
filters:
tags:
only: /^v.*/

- deploy:
requires:
- build
Expand All @@ -92,4 +99,7 @@ workflows:
- install_dependencies
- test:
requires:
- install_dependencies
- install_dependencies
- nuke_phx_devops:
requires:
- test
33 changes: 23 additions & 10 deletions commands/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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. WARNING: this will automatically delete all resources without any confirmation",
},
}

app.Action = errors.WithPanicHandling(awsNuke)
Expand Down Expand Up @@ -93,19 +97,28 @@ 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 {
logging.Logger.Infoln("The --force flag is set, so proceeding without confirmation.")
if err := aws.NukeAllResources(account, regions); err != nil {
return err
}
}

return nil
Expand Down

0 comments on commit 01ca5be

Please sign in to comment.