8.1: Set up failover event notifications

To receive notifications when failover events occur with your DB cluster, you will create an Amazon Simple Notification Service (SNS) topic, subscribe your email address to the SNS topic, create an RDS event subscription publishing events to the SNS topic and registering the DB cluster as an event source.

Open the Cloud9 console by referring to the CloudFormation with description “Amazon Aurora PostgreSQL Labs Stackset”, clicking on Outputs tab on the right and click on the Cloud9URL https address in “Value” column.

Open a Cloud9 terminal window by clicking Window and then New Terminal. Paste the following command to create an SNS topic.

aws sns create-topic \
--name auroralab-cluster-failovers

If successful, the command will respond back with a TopicArn identifier, you will need this value in the next command.

Next, subscribe your email address to the SNS topic using the command below, changing the placeholder [YourEmail] with your email address:

aws sns subscribe \
--topic-arn $(aws sns list-topics --query 'Topics[?contains(TopicArn,`auroralab-cluster-failovers`)].TopicArn' --output text) \
--protocol email \
--notification-endpoint '[YourEmail]'

You should see Output similar to the following:

You will receive a verification email on that address, please confirm the subscription by following the instructions in the email.

Once you click Confirm subscription in the email, you’ll see a browser window with a confirmation message as follows:

Once confirmed, or while you are waiting for the verification email to arrive, create an RDS event subscription and register the DB cluster as an event source using the command below:

If your Aurora cluster name is different than aupg-labs-cluster, update the command below accordingly.

aws rds create-event-subscription \
--subscription-name auroralab-cluster-failovers \
--sns-topic-arn $(aws sns list-topics --query 'Topics[?contains(TopicArn,`auroralab-cluster-failovers`)].TopicArn' --output text) \
--source-type db-cluster \
--event-categories '["failover"]' \
--enabled

aws rds add-source-identifier-to-subscription \
--subscription-name auroralab-cluster-failovers \
--source-identifier aupg-labs-cluster

At this time the event notifications have been configured. Ensure you have verified your email address before proceeding to the next section.