I have a docker compose project that I am trying to deploy to AWS. Amazons ECS service seemed like a good fit, however when I try to deploy using the ecs-cli up command like so:

ecs-cli up --capability-iam \                                                                                                               
  --keypair my-keypair \
  --size 4 \
  --vpc vpc-cc1ab3a8 \
  --subnets subnet-1f944e22,subnet-151b1d4c,subnet-63437548,subnet-323ad644 \
  --azs us-east-1a,us-east-1b,us-east-1d,us-east-1e

I get the following error in CloudFormation...

The availability zones of the specified subnets and the AutoScalingGroup do not match

Not exactly sure how to proceed. I'm still very new to AWS and after looking through the ECS docs, I couldn't find anything that directly addressed AutoScalingGroup.

I assume the error is because the created autoscaling group didn't match up to the specified subnets? How do I get them to match up?

  • Where did you get those subnet IDs? – EEAA Oct 28 '15 at 12:51
  • @EEAA they were listed under Subnets menu item in the VPC dashboard – Alex Fu Oct 28 '15 at 17:02
  • have you found solution? – Pleerock Dec 8 '15 at 16:10
  • @Pleerock I ended up just having ecs-cli create a new VPS for me instead of trying use an existing one with existing subnets. – Alex Fu Dec 31 '15 at 17:44
  • I would check and make sure the VPC, subnets, and availability zones you have specified all match up. I suspect you may have listed a subnet that is in a different AZ than you have listed. If you are having trouble with cloudformation and ECS you can check out Convox we built it to make managing and deploying a containerized app easy and it uses Cloudformation and ECS under the hood. – Cameron Gray Dec 12 '18 at 21:57

To work around this, you indeed seem to need all of --vpc, --subnets and --azs, but for some reason you can only specify exactly two AZs. In turn it then also needs exactly two matching subnets.

I could not get it to work in any other form.


Issue caused due to Availablity Zone specified in VPC and Availablity Zone specified in Auto scaling group doesn't match. Specify it correctly in ec client. Same issue occured to me also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.