segmentio / stack

A set of Terraform modules for configuring production infrastructure with AWS
https://open.segment.com
MIT License
2.1k stars 422 forks source link

ClusterContainsContainerInstancesException #38

Open tomdavidson opened 8 years ago

tomdavidson commented 8 years ago

Im more than a bit excited about Stack. This is not nit picking, but sharing info because I experience quite a few issues. Using Terrafrom 0.6.16.

On a fresh and branch new stack I have the following plan:


module "autoreg_stack" {
  source      = "github.com/segmentio/stack"
  environment = "iac"
  key_name    = "autoreg"
  name        = "autoreg-stack"
  domain_name = "autoreg-stack.local"
  region      = "us-west-2"
  availability_zones  = "us-west-2a,us-west-2b,us-west-2c"
  cidr        = "192.168.0.0/16"
  internal_subnets  = "192.168.0.0/19,192.168.64.0/19,192.168.128.0/19"
  external_subnets  = "192.168.32.0/20,192.168.96.0/20,192.168.160.0/20"
  ecs_instance_type = "t2.small"
  ecs_instance_ebs_optimized  = false
}

Unfortunately, apply does not make it all the way through:

Error applying plan:

1 error(s) occurred:

* aws_ecs_cluster.main: ClusterContainsContainerInstancesException: The Cluster cannot be deleted while Container Instances are active.
        status code: 400, request id: 8bc05c80-5089-11e6-a6e1-7bf5f1238842

But if I plan and apply again, then Terrafrom says there are no changes to be made.

achille-roussel commented 8 years ago

That is really odd... the error comes from the AWS API.

We're working with 0.6.15 here, so either the stack code relies on a bug prior to 0.6.16 or the latest terraform has introduced an issue (the latter seems more likely to me).

Can we confirm that there was no ECS cluster in your AWS account when you ran the first time?

tomdavidson commented 8 years ago

Tired 0.6.15 - same symptoms. There might have been an ECS cluster from a previous Stack experiment but it would have had a different name - are the modules created in such a way I can only have one Stack per AWS account?

achille-roussel commented 8 years ago

Things should work if you give a different name to your stacks and use different subnets etc... are all the stacks you use named differently?

tomdavidson commented 8 years ago

Yes, all named differently. Only two stacks in my test account. The second stack was just to see if it would happen again. Right now I am not able to reproduce because both stacks give me a cycle error #37

(Happen to know of a util to wipe out all provisioned resources of an aws account?)

andersonkyle commented 7 years ago

Charity Majors recommends tagging all resources with something like terraform: true. See this for more detail.

That way you can be more surgical when destroying resources out of band.