Connect to the Multi-AZ endpoint

RDS PostgreSQL does provide customers an option to simulate the AZ failure and High Availability by offering the option to reboot the Postgres Instance with the failover option. This option will initiate AZ level failover for the Instance, the instance on the secondary AZ will become primary, and the instance on the primary will become the new secondary.

  1. In the terminal window EC2 instance, enter and run these commands to showcase connection to the database at 10-second intervals:
while true;
do
psql -h rdspg-fcj-labs.cssuddr073hp.us-east-1.rds.amazonaws.com -U masteruser pglab; 
echo -e "\n\n"
sleep 10
done

Observe the output below. This output shows you the current IP address of the RDS PostgreSQL primary instance. In the next task, we will cause a failover and observe the change in the IP address as the primary instance changes. For now, leave this window open and let the command loop run. Proceed to the next task. HA

Configure Event subscription for Failover event

To be notified about Failover events (or other ones) we create RDS Event subscription for this lab.

  1. Open the Amazon RDS console and choose Event Subscriptions in the left pane.

  2. Click Create event subscription. HA

  3. We use an email subscription in this example - to get notifications over the email you provide: HA

And choose rdspg-fcj-labs instance from the list or use the All instances option, and select the Failover event type: HA

Before you can start receiving the event notifications via email you will need to verify your email address. You should receive a verificaiton email shortly after creating the subscription. HA

(OPTIONAL) AWS CLI

Alternatively you can create an Event Subscription using the AWS CLI as shown below:

Code