func (c *AWSCluster) Delete() { c.cf = cloudformation.New(c.creds, c.Region, nil) stackEventsSince := time.Now() c.base.setState("deleting") if err := c.fetchStack(); err != StackNotFoundError { if err := c.wrapRequest(func() error { return c.cf.DeleteStack(&cloudformation.DeleteStackInput{ StackName: aws.String(c.StackName), }) }); err != nil { err = fmt.Errorf("Unable to delete stack %s: %s", c.StackName, err) c.base.SendError(err) if !c.base.YesNoPrompt(fmt.Sprintf("%s\nWould you like to remove it from the installer?", err.Error())) { c.base.setState("error") return } } else if err := c.waitForStackCompletion("DELETE", stackEventsSince); err != nil { c.base.SendError(err) } } if err := c.base.MarkDeleted(); err != nil { c.base.SendError(err) } c.base.sendEvent(&Event{ ClusterID: c.base.ID, Type: "cluster_state", Description: "deleted", }) }
func (c *AWSCluster) SetCreds(creds *Credential) error { if creds == nil || creds.ID == "aws_env" { c.base.CredentialID = "aws_env" awsCreds, err := aws.EnvCreds() if err != nil { return err } c.creds = awsCreds } else { c.base.credential = creds c.base.CredentialID = creds.ID c.creds = aws.Creds(creds.ID, creds.Secret, "") } c.ec2 = ec2.New(c.creds, c.Region, nil) c.cf = cloudformation.New(c.creds, c.Region, nil) return nil }