# Automating Oracle Data Guard switchover and failover on Amazon EC2

DevFeed: [Automating Oracle Data Guard switchover and failover on Amazon EC2](<https://devfeed.tech/articles/automating-oracle-data-guard-switchover-and-failover-on-amazon-ec2-129580.md>)

Original publisher: [Read original article](<https://aws.amazon.com/blogs/database/automating-oracle-data-guard-switchover-and-failover-on-amazon-ec2/>)

Author: Sai Krishna Namburu

Published: 2026-11-11T17:50:50Z

Content type: article

Language: en

Sources: [AWS Database Blog](<https://devfeed.tech/sources/aws-database-blog.md>)

Topics: [AWS Step Functions](<https://devfeed.tech/topics/aws-step-functions.md>), [Disaster Recovery](<https://devfeed.tech/topics/disaster-recovery.md>), [Oracle Database](<https://devfeed.tech/topics/oracle-database.md>), [Amazon EC2](<https://devfeed.tech/topics/amazon-ec2.md>), [Amazon Web Services](<https://devfeed.tech/topics/aws.md>), [aws-sns](<https://devfeed.tech/topics/aws-sns.md>), [Amazon DynamoDB](<https://devfeed.tech/topics/amazon-dynamodb.md>), [Amazon CloudWatch](<https://devfeed.tech/topics/amazon-cloudwatch.md>)

Tags: [advanced-300](<https://devfeed.tech/tags/advanced-300.md>), [amazon-cloudwatch](<https://devfeed.tech/tags/amazon-cloudwatch.md>), [amazon-dynamodb](<https://devfeed.tech/tags/amazon-dynamodb.md>), [amazon-ec2](<https://devfeed.tech/tags/amazon-ec2.md>), [amazon-elastic-compute-cloud-amazon-ec2](<https://devfeed.tech/tags/amazon-elastic-compute-cloud-amazon-ec2.md>), [amazon-eventbridge](<https://devfeed.tech/tags/amazon-eventbridge.md>), [amazon-sns](<https://devfeed.tech/tags/amazon-sns.md>), [automate](<https://devfeed.tech/tags/automate.md>), [availability](<https://devfeed.tech/tags/availability.md>), [aws-cloudformation](<https://devfeed.tech/tags/aws-cloudformation.md>), [aws-lambda](<https://devfeed.tech/tags/aws-lambda.md>), [aws-secrets-manager](<https://devfeed.tech/tags/aws-secrets-manager.md>), [aws-step-functions](<https://devfeed.tech/tags/aws-step-functions.md>), [aws-systems-manager](<https://devfeed.tech/tags/aws-systems-manager.md>), [database](<https://devfeed.tech/tags/database.md>), [disaster-recovery](<https://devfeed.tech/tags/disaster-recovery.md>), [failover](<https://devfeed.tech/tags/failover.md>), [high-availability](<https://devfeed.tech/tags/high-availability.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [oracle](<https://devfeed.tech/tags/oracle.md>), [rto](<https://devfeed.tech/tags/rto.md>), [technical-how-to](<https://devfeed.tech/tags/technical-how-to.md>)

## AI overview

The solution automates Oracle Data Guard role transitions on Amazon EC2 with AWS Step Functions coordinating AWS Lambda tasks. It uses Systems Manager Run Command for database operations, Secrets Manager for SYS credentials, SNS for stage notifications, CloudWatch for execution logs, and DynamoDB for event records. Planned switchovers run 13 pre-checks and eight post-checks; blocking failures halt execution, and the primary workload should be quiesced so redo lag reaches zero. Emergency failovers run 10 standby-focused checks, confirm the primary is unreachable, and capture SCN, timestamps, and log gaps to report potential RPO impact; the former primary may need reinstatement. Prerequisites include configured Data Guard Broker, Flashback, connectivity, SYSDBA access, static listener entries, SSM agents and permissions, a stored SYS password, and an SNS subscription. The described implementation supports one database within the same account and Region, was tested with Oracle Database 19c, and requires Python 3.9+ for Lambda.

## Source excerpt

Oracle Data Guard keeps a standby database in sync for high availability and disaster recovery, but running switchover and failover by hand on Amazon EC2 is slow and error-prone. This post shows how to automate both with AWS Step Functions and AWS Lambda, running validated pre-checks, the role transition, post-checks, and RTO/RPO tracking end to end.