Overview
I was working on creating HAproxy setup in AWS EC2 for high availability, to do that I had to write a small bash script which is running on my monitoring server (not in Amazon region)
The script changes EIP of a faulty EC2 HAproxy instance to working standby HAproxy EC2 instance.
Assumptions
HAproxy servers are running in Aws Ec2 in same region with EIP
HAproxy-Master - Ec2 instance which is working as main server for my setup
HAproxy-Slave - Ec2 instance which is working as a standby instance in my setup.
Monitoring server - The server which is working as monitoring server and also not hosted in aws environment.
Haproxy-master and HAproxy-slave instances are in same region.
Prerequisite
Aws Ec2 API command line tool is installed on monitoring server.
Elastic IP assign to both instances
Script