Browse Source

Detect stack already exists

This will later be used to switch to ChangeSet logic

Signed-off-by: Nicolas De Loof <[email protected]>
Nicolas De Loof 5 years ago
parent
commit
87f053d710
2 changed files with 10 additions and 1 deletions
  1. 0 1
      ecs/pkg/amazon/cloudformation.go
  2. 10 0
      ecs/pkg/amazon/up.go

+ 0 - 1
ecs/pkg/amazon/cloudformation.go

@@ -14,7 +14,6 @@ import (
 
 func (c client) Convert(project *compose.Project, loadBalancerArn *string) (*cloudformation.Template, error) {
 	template := cloudformation.NewTemplate()
-
 	vpc, err := c.GetDefaultVPC()
 	if err != nil {
 		return nil, err

+ 10 - 0
ecs/pkg/amazon/up.go

@@ -10,6 +10,16 @@ import (
 )
 
 func (c *client) ComposeUp(project *compose.Project, loadBalancerArn *string) error {
+	stacks, err := c.CF.DescribeStacks(&cloudformation.DescribeStacksInput{
+		StackName: aws.String(project.Name),
+	})
+	if err != nil {
+		return err
+	}
+	if len(stacks.Stacks) > 0 {
+		return fmt.Errorf("we do not (yet) support updating an existing CloudFormation stack")
+	}
+
 	template, err := c.Convert(project, loadBalancerArn)
 	if err != nil {
 		return err