in term/term.go [52:92]
func Terminate(d deps.Deps, app string, account string, region string, stack string, cluster string) error {
enabled, err := d.MonkeyCfg.Enabled()
if err != nil {
return errors.Wrap(err, "not terminating: could not determine if monkey is enabled")
}
if !enabled {
log.Println("not terminating: enabled=false")
return nil
}
problem, err := d.Ou.Outage()
// If the check for ongoing outage fails, we err on the safe side nd don't terminate an instance
if err != nil {
return errors.Wrapf(err, "not terminating: problem checking if there is an outage")
}
if problem {
log.Println("not terminating: outage in progress")
return nil
}
accountEnabled, err := d.MonkeyCfg.AccountEnabled(account)
if err != nil {
return errors.Wrap(err, "not terminating: could not determine if account is enabled")
}
if !accountEnabled {
log.Printf("Not terminating: account=%s is not enabled in Chaos Monkey", account)
return nil
}
// create an instance group from the command-line parameters
group := grp.New(app, account, region, stack, cluster)
// do the actual termination
return doTerminate(d, group)
}