Setting region is required if you are not using default region 'us-east-1'.
If your ELB is not in us-east-1, and you do not specify region parameter as above,
you will get an error indicating that no ELB could be found with that name in that region.

In order to define your instance sets associated with your load balancer based deploys, you must specify the load balancer name, the associated roles for that load balancer and any optional params:
For example, in deploy.rb, you would enter the load balancer name (e.g. 'lb_webserver'), the capistrano role associated with that load balancer (.e.g. 'web'),
and any optional params.

There are two special optional parameters you can add, :require and :exclude. These allow you to exclude instances associated with your named load balancer from the deploy,
if they meet or fail to meet your :require/:exclude specifications.

The :require and :exclude parameters work on Amazon EC2 instance metadata.

AWS instances have top level metadata and user defined tag data, and this data can be used by your loadbalancer rule
to include or exclude certain instances from the instance set.

Take the :require keyword; Lets say we only want to deploy to AWS instances which are in the 'running' state. To do that:

loadbalancer:lb_appserver,:app,:require=>{:aws_state=>"running"}

The server set defined here for role :app are all instances in the loadbalancer 'lb_appserver' with aws_state set to 'running'.

Perhaps you have added tags to your instances, if so, you might want to deploy to only the instances meeting a specific tag value:

The server set defined here for role :app are all instances in the loadbalancer 'lb_appserver' with aws_state set to 'running',
and that have the named 2 tags set, with exactly those values for each. There can be other tags in the instance, but the named tags in the rule must be present
for the given instance to make it into the server set.

Now consider the :exclude keyword; Lets say we do not want to deploy to AWS instances which are 'micro' sized. To do that:

When your capistrono script is complete, you can deploy to all instances within the ELB that meet your criteria with:

% cap deploy

Here's an example of a task that does a quick list of the instance ids (if any) within the load balancer associated with the 'app' role
that meets the criteria you laid out in the loadbalancer definition line,
add this to your cap deploy file:

# run with cap ec2:listnamespace:ec2dodesc"list instances"task:list,:roles=>:appdorun"hostname"endend

This will give you the list of hosts behind the load balancer that meet the criteria.
% cap ec2:list

Version Informatoin

Version 0.2.0 - ELBs behind VPCs didn't work on all 0.1.x, due to no :dns_name for VPC shielded hosts. Now we fall back to IP addresses in 0.2.x and above