compose/ecs/pkg/amazon/down.go
Nicolas De Loof a8e963a304
Query stack events by stack ID (not name)
This prevent a race condition on `down` as stack is deleted and we still
ask for stack events as we didn't recieved the DELETE_COMPLETE one

Use WaitUntilStack* to detect stack operation completion

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2020-08-17 21:25:44 +02:00

35 lines
652 B
Go

package amazon
import (
"context"
"fmt"
)
func (c *client) ComposeDown(ctx context.Context, projectName string, deleteCluster bool) error {
err := c.api.DeleteStack(ctx, projectName)
if err != nil {
return err
}
err = c.WaitStackCompletion(ctx, projectName, StackDelete)
if err != nil {
return err
}
if !deleteCluster {
return nil
}
fmt.Printf("Delete cluster %s", c.Cluster)
if err = c.api.DeleteCluster(ctx, c.Cluster); err != nil {
return err
}
fmt.Printf("... done. \n")
return nil
}
type downAPI interface {
DeleteStack(ctx context.Context, name string) error
DeleteCluster(ctx context.Context, name string) error
}