17.8 Upgrading RDS: Minor Versions, Major Versions, and Blue/Green Deployments
Alright, let’s talk about upgrading your RDS instances. This isn’t like updating an app on your phone where you just hit “install” and hope for the best. This is your production database we’re talking about. Screw this up, and you’re the one explaining to everyone why the website is down at 2 AM. So let’s get it right.
The first thing to wrap your head around is that AWS manages the database software, but you are still the one holding the big red button that says “UPGRADE.” They handle the patching and the heavy lifting of the actual install, but you have to approve and schedule the change. It’s a partnership, and you’re the one who signs the permission slip.
The Two Flavors of Upgrades: Minor vs. Major
You need to understand the fundamental difference between these two, because the implications are night and day.
A minor version upgrade (e.g., PostgreSQL 13.4 to 13.7) is typically a walk in the park. These are usually patches for bugs, security vulnerabilities, or performance improvements. They’re often backwards-compatible and low-risk. AWS will sometimes even apply these automatically during your maintenance window if you’ve configured it to do so. It’s basically like getting your teeth cleaned; mildly inconvenient if it causes a 30-second failover, but ultimately a good idea.
A major version upgrade (e.g., PostgreSQL 13 to 14) is a whole different beast. This is invasive surgery. You’re moving to a new version of the database engine that can have breaking changes in SQL syntax, data types, system functions, and the internal storage format. This is not automatic for a very good reason: your application might break spectacularly. You absolutely must test this upgrade path thoroughly on a staging environment first. Do not skip this. I’m serious.
How to Actually Do a Standard Upgrade
Let’s say you’ve done your testing and you’re ready to perform a major version upgrade on your my-database instance. You can do this via the console (clicky-clicky) or, like a proper engineer, with the CLI. The magic incantation is modify-db-instance.
# This command kicks off the upgrade process
aws rds modify-db-instance \
--db-instance-identifier my-database \
--engine-version 14.6 \
--allow-major-version-upgrade \
--apply-immediately
A few critical flags here:
--allow-major-version-upgrade: This is AWS making you type “I know what I’m doing.” Without it, the command will fail for a major version jump.--apply-immediately: This says “do it now, don’t wait for the next maintenance window.” If you omit this, the upgrade will be pending until your specified window. For a production upgrade, you probably want to control the timing precisely, so using this flag and running it at 2 AM on a Tuesday is often the way to go.
What happens next? RDS will take your instance, spin up a new one on the new version (often using a logical backup/restore or a snapshot), and then switch over. This means downtime. The length of that downtime is directly proportional to the size of your database. For a large instance, we’re talking hours.
The Savior: Blue/Green Deployments
If the thought of hours of downtime makes you break out in a cold sweat, meet your new best friend: Blue/Green Deployments. This is the professional, low-downtime way to do this.
The concept is brilliantly simple. You tell RDS to create a Green environment—a completely separate, synchronized copy of your production (Blue) database, but running the new engine version you specified. This Green environment is a fully functional RDS instance in its own right. Your production Blue instance keeps humming along, completely untouched, serving traffic.
You can now connect your application’s staging environment to the Green database and run every test in your book against the actual production data and new engine. Once you’re supremely confident, you promote the Green environment to be the new production. The promotion switchover typically only takes a minute or two of downtime. It’s a full cut-over, not a gradual rollout.
# First, create the Green deployment
aws rds create-blue-green-deployment \
--blue-green-deployment-name my-db-upgrade \
--source arn:aws:rds:us-east-1:123456789012:db:my-database \
--target-engine-version 14.6
# ... Test extensively on the green endpoint ...
# Then, when you're ready, promote it
aws rds switchover-blue-green-deployment \
--blue-green-deployment-identifier bg-whd71zxf6f7example \
--switchover-timeout 600
The best part? If you discover a show-stopping bug after the promotion, you can switch back to the Blue environment. This safety net is worth its weight in gold.
The Gotchas and Best Practices
- Parameter Groups: Your existing parameter group is probably tied to your old engine version. You’ll often need to create a new parameter group compatible with your new major version and associate it with your instance (or Green deployment) before upgrading. If you forget this, the upgrade will fail spectacularly.
- Extensions: For love of all that is holy, check your database extensions. Are they compatible with the new major version? You might need to update them beforehand.
SELECT * FROM pg_extension;is your friend. - Test, Then Test Again: I don’t mean run one query. I mean run your full application test suite, performance benchmarks, the works. The Green deployment feature makes this easy—use it.
- Backup: Always, always, take a final snapshot manually right before you kick off the upgrade. It’s your “oh crap” handle. Name it something like
pre-upgrade-backup-for-the-love-of-god.
The bottom line? Minor upgrades are routine. Major upgrades are a project. Plan it, test it, and use Blue/Green if you value your sleep and your job. It’s one of the best features AWS has added to RDS in years.