It is far too common for AWS to have no instances of the requested type available in an availability zone. Docker’s CloudFormation template always asks for the first two zones in the list of available zones from the region in which you deploy. If one of those zones does not have available ec2 instances matching your type you get this error.
Just a while ago I had to modify the Docker CloudFormation template and replace the selection of the first two zones with some input parameters, so I could choose the AZs where the images would be created. I was able to choose us-east-1c and us-east-1d and everything worked fine.
It is not difficult to make this change to the template. But you have to do it again when Docker releases a new template unless they build this into a future version.
Changing the availability zone selection from the first two to the first and third resolved the issue. It would be great to add a prompt for the user to select availability zones based on the region in the next template update.
Yes indeed, and this is pretty easy to do. I did just that, in fact. I find that in us-east-1 the first two AZs (a, and b) are quite frequently full. Probably because people tend to select the AZs from the beginning of the list.
Add two parameters to the parameters section of the template:
"Subnet1Zone" : {
"Description" : "First AZ, for the first subnet",
"Type" : "String"
},
"Subnet2Zone" : {
"Description" : "Second AZ, for the second subnet",
"Type" : "String"
}
Then change the two places where the Subnets are chosen from:
Make sure to get both AvailabilityZones, one for each subnet.
The bad part about making this change is that you will have to do it again with the next template released. I personally prefer to have separate templates: 1 for the VPC and networking, 1 for security, and 1 for the application resources such as EC2 Instances, ELBs, ASGs, SQS, etc.
Great article, and of big help. I was able to update my own parameters for the Northern California region to only use us-west-1a and us-west-1c (us-west-1b was throwing the error mentioned above).
Unfortunately, the template as it is today requires 3 subnets in unique availability zones. This means I must have 3 unique AZs. Am abandoning using Northern California as a result, and will see if I can manage to get 2 AZs in other regions. If anyone has an idea (something I have missed?), please let me know!