Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save tkuchiki/f3f6661d13994185e438 to your computer and use it in GitHub Desktop.

Select an option

Save tkuchiki/f3f6661d13994185e438 to your computer and use it in GitHub Desktop.
ELB の health check を設定する
#!/bin/bash
usage() {
echo "Usage: $(basename $0) -e|--elb ELB_NAME -t|--target TARGET
-e|--elb elb name
-t|--target target protocol (http|tcp)
-h|--help show this help message and exit
"
exit 0
}
OPT=$(getopt -q -o e:t:h -l elb:,target:,help -- "${@}")
eval set -- "${OPT}"
TARGET=""
ELB=""
while :; do
case "${1}" in
-e|--elb) ELB="${2}"; shift 2 ;;
-t|--target) TARGET="${2}"; shift 2 ;;
-h|--help) usage ;;
--) shift; break ;;
*) echo "Internal error!" 1>&2; exit 1 ;;
esac
done
if [ "${TARGET}" = "" -o "${ELB}" = "" ]; then
usage
fi
COMMON="Interval=6,Timeout=5,UnhealthyThreshold=2,HealthyThreshold=10,Target="
case "${TARGET}" in
tcp) HEALTH_CHECK="${COMMON}TCP:80" ;;
http) HEALTH_CHECK="${COMMON}HTTP:80/ping" ;;
*) echo "invalid value(http or tcp)"; exit 1 ;;
esac
#export AWS_CONFIG_FILE=/path/to/.aws/config
aws elb configure-health-check --load-balancer-name $ELB --health-check $HEALTH_CHECK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment