How to deploy to a specific availability zone

To deploy to specific availability zones the --constraints option is used. It is supported by commands bootstrap, deploy, and add-machine.

The constraint type that is used to do this is ‘zones’. This is not to be confused with the ‘zone’ placement directive, which happens to take precedence over the constraint.

For instance, here we create two Trusty machines in a certain zone:

juju add-machine -n 2 --series trusty --constraints zones=us-east-1a

We then deploy an application on two new machines in a different zone:

juju deploy redis -n 2 --constraints zones=us-east-1c

Finally, in order to deploy units to the two empty machines in the initial zone we first change the application constraint default (set implicitly with the deploy command):

juju set-constraints redis zones=us-east-1a
juju add-unit redis -n 2

When multiple (comma separated) values are used, the constraint is interpreted as being a range of zones where a machine must end up in.