Last active
August 7, 2024 10:26
-
-
Save huevos-y-bacon/80892f8de5c8d67db6d870fdfe95c15e to your computer and use it in GitHub Desktop.
AWS ALB (Classic) - REGISTER OR DEREGISTER INSTANCES WITH/FROM ELB CLASSIC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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