Skip to content

Commit 3e8f7a8

Browse files
committed
automatically set ELB_LIST if not provided
1 parent ada6322 commit 3e8f7a8

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

load-balancing/elb/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,5 @@ To use these scripts in your own application:
4646
1. Copy the `.sh` files in this directory into your application source.
4747
1. Edit your application's `appspec.yml` to run `deregister_from_elb.sh` on the ApplicationStop event,
4848
and `register_with_elb.sh` on the ApplicationStart event.
49-
1. Edit `common_functions.sh` to set `ELB_LIST` to contain the name(s) of the Elastic Load
50-
Balancer(s) your deployment group is a part of. Make sure the entries in ELB_LIST are separated by space.
5149
1. Deploy!
5250

load-balancing/elb/common_functions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# permissions and limitations under the License.
1515

1616
# ELB_LIST defines which Elastic Load Balancers this instance should be part of.
17-
# The elements in ELB_LIST should be seperated by space.
17+
# The elements in ELB_LIST should be separated by space.
1818
ELB_LIST=""
1919

2020
# Under normal circumstances, you shouldn't need to change anything below this line.

load-balancing/elb/deregister_from_elb.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ msg "Instance is not part of an ASG, continuing..."
5252

5353
msg "Checking that user set at least one load balancer"
5454
if test -z "$ELB_LIST"; then
55-
error_exit "Must have at least one load balancer to deregister from"
55+
msg "Finding all the ELBs that this instance is registered to"
56+
get_elb_list $INSTANCE_ID
57+
if [ $? != 0 ]; then
58+
error_exit "Must have at least one load balancer to deregister from"
59+
fi
60+
echo "$ELB_LIST" > /tmp/elblist
5661
fi
5762

5863
# Loop through all LBs the user set, and attempt to deregister this instance from them.

load-balancing/elb/register_with_elb.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ msg "Instance is not part of an ASG, continuing..."
5252

5353
msg "Checking that user set at least one load balancer"
5454
if test -z "$ELB_LIST"; then
55-
error_exit "Must have at least one load balancer to register to"
55+
if [ -a /tmp/elblist ]; then
56+
msg "Finding all the ELBs that this instance was previously registered to"
57+
read ELB_LIST < /tmp/elblist
58+
rm -f /tmp/elblist
59+
else
60+
error_exit "Must have at least one load balancer to register to"
61+
fi
5662
fi
5763

5864
# Loop through all LBs the user set, and attempt to register this instance to them.

0 commit comments

Comments
 (0)