Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion load-balancing/elb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ To use these scripts in your own application:
1. Copy the `.sh` files in this directory into your application source.
1. Edit your application's `appspec.yml` to run `deregister_from_elb.sh` on the ApplicationStop event,
and `register_with_elb.sh` on the ApplicationStart event.
1. Edit `common_functions.sh` to set `ELB_LIST` to contain the name(s) of the Elastic Load
1. If your instance is not in an Auto Scaling Group,
edit `common_functions.sh` to set `ELB_LIST` to contain the name(s) of the Elastic Load
Balancer(s) your deployment group is a part of. Make sure the entries in ELB_LIST are separated by space.
Alternatively, you can set `ELB_LIST` to `all` to automatically use all load balancers the instance is
registered to.
1. Deploy!

3 changes: 2 additions & 1 deletion load-balancing/elb/common_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
# permissions and limitations under the License.

# ELB_LIST defines which Elastic Load Balancers this instance should be part of.
# The elements in ELB_LIST should be seperated by space.
# The elements in ELB_LIST should be separated by space.
# Set to "all" to automatically find all load balancers the instance is registered to.
ELB_LIST=""

# Under normal circumstances, you shouldn't need to change anything below this line.
Expand Down
9 changes: 9 additions & 0 deletions load-balancing/elb/deregister_from_elb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ fi

msg "Instance is not part of an ASG, continuing..."

if [ "${ELB_LIST}" = all ]; then
msg "Finding all the ELBs that this instance is registered to"
get_elb_list $INSTANCE_ID
if [ $? != 0 ]; then
error_exit "Must have at least one load balancer to deregister from"
fi
echo "$ELB_LIST" > /tmp/elblist
fi

msg "Checking that user set at least one load balancer"
if test -z "$ELB_LIST"; then
error_exit "Must have at least one load balancer to deregister from"
Expand Down
10 changes: 10 additions & 0 deletions load-balancing/elb/register_with_elb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ fi

msg "Instance is not part of an ASG, continuing..."

if [ "${ELB_LIST}" = all ]; then
if [ -a /tmp/elblist ]; then
msg "Finding all the ELBs that this instance was previously registered to"
read ELB_LIST < /tmp/elblist
rm -f /tmp/elblist
else
error_exit "Must have at least one load balancer to register to"
fi
fi

msg "Checking that user set at least one load balancer"
if test -z "$ELB_LIST"; then
error_exit "Must have at least one load balancer to register to"
Expand Down