| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package amazon
- import (
- "context"
- "fmt"
- "github.com/awslabs/goformation/v4/cloudformation"
- "github.com/docker/ecs-plugin/pkg/compose"
- )
- func (c *client) ComposeUp(ctx context.Context, project *compose.Project) error {
- ok, err := c.api.ClusterExists(ctx, c.Cluster)
- if err != nil {
- return err
- }
- if !ok {
- c.api.CreateCluster(ctx, c.Cluster)
- }
- update, err := c.api.StackExists(ctx, project.Name)
- if err != nil {
- return err
- }
- if update {
- return fmt.Errorf("we do not (yet) support updating an existing CloudFormation stack")
- }
- template, err := c.Convert(ctx, project)
- if err != nil {
- return err
- }
- err = c.api.CreateStack(ctx, project.Name, template)
- if err != nil {
- return err
- }
- return c.WaitStackCompletion(ctx, project.Name, StackCreate)
- }
- type upAPI interface {
- waitAPI
- ClusterExists(ctx context.Context, name string) (bool, error)
- CreateCluster(ctx context.Context, name string) (string, error)
- StackExists(ctx context.Context, name string) (bool, error)
- CreateStack(ctx context.Context, name string, template *cloudformation.Template) error
- }
|