Quantcast
Channel: Technical Blog for Software Enthusiasts
Viewing all articles
Browse latest Browse all 26

ELB (Elastic Load Balancer) Utilities - Customizing AWS Elastic Beanstalk

$
0
0
AWS Elastic Beanstalk environment by default installs ELB command line utilites. You can read more about ELB here and its documentation is available here. All the AWS command line utilities require few environment variables. You can read about them in the Amazon documentation and we shall cover them soon in one of our future blog posts.

We needed few more custom utilities that we make use of and we at hudku.com carry all these utility scripts in the directory scripts/util. These utilities could be used if you are just using AWS and not necessarily Elastic Beanstalk.

Please leave a comment in case if you notice any error in the scripts, if any point is overlooked or if any improvement can be made.

Here are the ELB utilities we use. The description in the beginning of each file describe the purpose of each script.

elb-contains-ec2-instance.sh
#!/bin/bash # Execute "export DEBUG=1" to debug this script. # Set value to 2 to debug this script and the scripts called within this script. # Set value to 3,4,5 and so on to increase the nesting level of the scripts to be debugged. [[ $DEBUG -gt 0 ]] && set -x; export DEBUG=$(($DEBUG - 1)) # # Given ELB name and EC2 instance id determine whether the EC2 instance is member of the specified ELB. # display_usage() { echo -e "\nUsage: $0 elbName ec2InstanceId\n" } # Check the argument count if [ $# -ne 2 ]; then display_usage exit 2 fi elbName=$1 ec2InstanceId=$2 result=$(elb-describe-instance-health $elbName $ec2InstanceId | awk '{print $2}') if ([ "$result" != "$ec2InstanceId" ]) then echo "no" exit 1 fi echo "yes"
elb-get-hosted-zone-id-from-url.sh
#!/bin/bash # Execute "export DEBUG=1" to debug this script. # Set value to 2 to debug this script and the scripts called within this script. # Set value to 3,4,5 and so on to increase the nesting level of the scripts to be debugged. [[ $DEBUG -gt 0 ]] && set -x; export DEBUG=$(($DEBUG - 1)) # # Given an ELB URL obtain its Hosted Zone ID. Needed to make Route53 entries. # display_usage() { echo -e "\nUsage: $0 elbURL\n" } # Check the argument count if [ ! $# == 1 ]; then display_usage exit 2 fi elbURL=$1 elbHostedZoneID=$(elb-describe-lbs --show-long | grep -i $elbURL | cut -d, -f5) echo $elbHostedZoneID
elb-get-name-from-url.sh
#!/bin/bash # Execute "export DEBUG=1" to debug this script. # Set value to 2 to debug this script and the scripts called within this script. # Set value to 3,4,5 and so on to increase the nesting level of the scripts to be debugged. [[ $DEBUG -gt 0 ]] && set -x; export DEBUG=$(($DEBUG - 1)) # # Given an ELB URL obtain its name. # display_usage() { echo -e "\nUsage: $0 elbURL\n" } # Check the argument count if [ ! $# == 1 ]; then display_usage exit 2 fi elbURL=$1 elbName=$(elb-describe-lbs --show-long | grep -i $elbURL | cut -d, -f2) echo $elbName
elb-get-url-from-ip.sh
#!/bin/bash # Execute "export DEBUG=1" to debug this script. # Set value to 2 to debug this script and the scripts called within this script. # Set value to 3,4,5 and so on to increase the nesting level of the scripts to be debugged. [[ $DEBUG -gt 0 ]] && set -x; export DEBUG=$(($DEBUG - 1)) # # Given an IP address obtain the ELB URL if the IP is actually pointing to an Elastic Load Balancer. # # include all the utility scripts source $ELASTICBEANSTALK_APP_SCRIPT_DIR/include/include.sh display_usage() { echo -e "\nUsage: $0 ip\n" } # Check the argument count if [ ! $# == 1 ]; then display_usage exit 2 fi ip=$1 result="" aelbURL=$(elb-describe-lbs | awk '{print $3}') for elbURL in $aelbURL do elbIP=$(getIPOfURL $elbURL) if ([ "$elbIP" == "$ip" ]) then result=$elbURL break fi done echo $result
elb-get-url-from-name.sh
#!/bin/bash # Execute "export DEBUG=1" to debug this script. # Set value to 2 to debug this script and the scripts called within this script. # Set value to 3,4,5 and so on to increase the nesting level of the scripts to be debugged. [[ $DEBUG -gt 0 ]] && set -x; export DEBUG=$(($DEBUG - 1)) # # Given an ELB name obtain its URL. # display_usage() { echo -e "\nUsage: $0 elbName\n" } # Check the argument count if [ ! $# == 1 ]; then display_usage exit 2 fi elbName=$1 elbURL=$(elb-describe-lbs $elbName | awk '{print $2}') echo $elbURL

Viewing all articles
Browse latest Browse all 26

Trending Articles