Skip to content

Instantly share code, notes, and snippets.

@huevos-y-bacon
Last active March 29, 2022 16:23
Show Gist options
  • Save huevos-y-bacon/80892f8de5c8d67db6d870fdfe95c15e to your computer and use it in GitHub Desktop.
Save huevos-y-bacon/80892f8de5c8d67db6d870fdfe95c15e to your computer and use it in GitHub Desktop.
REGISTER OR DEREGISTER INSTANCES WITH/FROM ELB CLASSIC
#!/usr/bin/env bash
# REGISTER OR DEREGISTER INSTANCES WITH/FROM ELB CLASSIC
## SANDBOX/PLAY ACCOUNT
ELBNAME=23feb22
INSTANCES=(
i-0673baad826269229 # Name: dummy1
i-0a72c8136b4ee5042 # Name: dummy2
)
deregister(){
echo "Instances to deregister: ${INSTANCES[*]}"
aws elb deregister-instances-from-load-balancer \
--load-balancer-name ${ELBNAME} \
--instances ${INSTANCES[*]} \
--out yaml
}
register(){
echo "Instances to register: ${INSTANCES[*]}"
aws elb register-instances-with-load-balancer \
--load-balancer-name ${ELBNAME} \
--instances ${INSTANCES[*]} \
--out yaml
}
DO=$1
if [[ "$DO" == "register" ]] || [[ "$DO" == "deregister" ]]; then
echo "Load balancer: ${ELBNAME}"
echo "Action: ${DO}"
${DO}
else echo "No action $DO"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment