1
votes

I have written a cloudformation template for launching my stack. My requirement is to have all the instances to be in the same Availability Zone (AZ) rather than being in multiple AZs. I am using autoscaling group and hence I am unable to launch instances in the same AZ.

If instances launch on different AZs I cannot migrate persistent docker containers from one instance to another as flocker uses EBS volumes.

Any workaround for this would be a great help.

Thank you.

2
Please show your template.tedder42

2 Answers

1
votes

I think if you specify the Placement group or Subnet in your cloud formation template, you should be able to do it.
Please refer Placement Group in Ec2 Cloud Formation and Subnet in Cloud Formation to learn about the exact way to specify these.
If you specify a placement group for your instances, they will be created in the same placement group in same Availability Zone (AZ). If you specify subnet, they will be created in the same subnet of the same AZ.

Also, if your autoscaling group is restricted to a single AZ, even that should work. See Autoscaling Group CloudFormation

0
votes

This is really easy. AZs are specified on the Subnet level. Create a subnet in your VPC in your desired AZ eg. eu-west-1.

On your Auto Scaling group, specify this subnet and no others.

Done. Newly launched instances will be launched into this new subnet and AZ.

NOTE: If there are already existing instances in this Auto Scaling Group in different subnets, you'll need to terminate them and let Auto Scaling do the work and launch replacements.