The Amazon RDS r-family latest generation policy flags memory-optimized Amazon RDS DB instances on a previous class, such as db.r3 or db.r4, and recommends db.r5. In US East (N. Virginia), db.r5.large costs the same per hour as db.r4.large for RDS for MySQL, with more memory and a faster processor. Apply this policy to any aws_db_instancewhose instance_class starts with db.r3. or db.r4..
Attribute | Detail |
|---|---|
Cloud Provider | Amazon Web Services (AWS) |
Resource Type | Amazon RDS memory-optimized DB instances, r-family |
Terraform Attribute |
|
Non-compliant Values | Previous r-family classes, for example |
Compliant Value | A current generation class such as |
Cost Impact | Same on-demand rate for db.r4 and db.r5 in US East for RDS for MySQL, with 16 GiB instead of 15.25 GiB of memory and a 3.1 GHz processor instead of 2.3 GHz |
Why This Policy Matters
How It Helps Reduce Cloud Costs
Amazon RDS r-family DB instances are memory-optimized. Teams run them for relational databases with large working sets, where keeping hot data in memory matters more than raw CPU.
An Amazon RDS db.r4.large runs on an Intel Xeon E5-2686 v4 (Broadwell) processor at 2.3 GHz. A db.r5.large runs on an Intel Xeon Platinum 8175 (Skylake-SP) processor at up to 3.1 GHz, with 16 GiB of memory instead of 15.25 GiB.
The db.r5 class keeps the 1:8 vCPU to memory ratio and scales to db.r5.24xlarge, with 96 vCPUs and 768 GiB of memory. The largest db.r4 class, db.r4.16xlarge, stops at 64 vCPUs and 488 GiB.
The Amazon RDS r-family upgrade is a price-performance fix, not a price cut. AWS charges the same hourly rate for db.r4 and db.r5 in many engine and region combinations. Staying on db.r4 buys less database for the same bill.
That gap turns into real savings when a database runs one size larger than it needs to. A faster processor and extra memory per class often let a team move down one size after testing.
Potential Savings
Amazon RDS r-family pricing is flat across recent Intel generations. The savings come from capacity per dollar, plus the option to downsize.
Instance class | vCPUs | Memory | Approx. monthly on-demand cost (RDS for MySQL, US East, Single-AZ) |
|---|---|---|---|
| 2 | 15.25 GiB | $175 |
| 2 | 15.25 GiB | $175 |
| 2 | 16 GiB | $175 |
Monthly figures assume 730 hours at list on-demand rates. Prices vary by engine, region, deployment option, and purchase option, and Multi-AZ deployments cost roughly double.
Downsizing is where the dollar savings appear. Each step down within the Amazon RDS r-family halves the instance cost. Moving a db.r4.2xlarge workload to db.r5.xlarge after load testing cuts its instance spend by about 50%.
Not every workload can drop a size. For those, the Amazon RDS r-family upgrade still adds memory and CPU headroom at no extra hourly cost.
Implementation Guide
Infrastructure-as-Code Example (Terraform)
The following examples show an Amazon RDS DB instance on a previous r-family class, and the corrected configuration on db.r5.
Non-compliant configuration: Amazon RDS DB instance on db.r4
This configuration pays the same hourly rate as db.r5.large for an older Broadwell processor and less memory. This is a common source of wasted spend in long-lived AWS accounts.
Compliant configuration: Amazon RDS DB instance on db.r5
The instance_class value is the only functional change. Setting apply_immediately = false defers the class change to the next preferred maintenance window instead of restarting the database on apply.
Terraform updates the existing Amazon RDS DB instance in place. The data, endpoint, and identifier stay the same.
Step-by-Step Fix Instructions
Search Terraform code for
instance_classvalues that start withdb.r3.ordb.r4.inaws_db_instanceresources.Check shared modules,
.tfvarsfiles, and variable defaults. Old instance classes often live in avariable "instance_class"default rather than the resource block.Confirm the target class supports your engine and engine version with
aws rds describe-orderable-db-instance-options.Decide whether to keep the same size or test one size smaller. Use CloudWatch
CPUUtilizationandFreeableMemoryfrom the last 30 days.Change
instance_class, and setapply_immediately = falseif the change should wait for the maintenance window.Run
terraform planand confirm it shows an in-place update toinstance_class, not a replacement of the Amazon RDS DB instance.Apply the change. Roll it out to non-production databases first to catch parameter group or engine version issues early.
Add Infracost to CI/CD so new previous-generation Amazon RDS r-family classes are flagged in pull requests before they merge.
Best Practices
Pin approved Amazon RDS instance classes in shared Terraform modules with a
validationblock, so previous-generation classes fail atterraform plan.Schedule production class changes for Multi-AZ databases where possible. On a Multi-AZ deployment, the change completes with a failover instead of a full restart.
Review Reserved Instances before migrating. An Amazon RDS Reserved Instance covers a specific instance family, so a db.r4 reservation does not apply to db.r5 usage.
Treat Graviton classes such as db.r6g as a separate decision. They cost less per hour but need engine version support and testing.
This policy is most valuable for databases created years ago and never revisited. New databases rarely start on db.r4 unless an old module default is still in use.
Tools and Scripts
How does Infracost detect previous-generation Amazon RDS r-family instances automatically?
The Amazon RDS r-family latest generation policy is available in Infracost, including in the free trial. When Infracost runs in CI/CD, it checks Amazon RDS resources in each pull request. Previous-generation r-family classes are flagged in the PR comment, with the file and line to change.
The same Infracost pull request comment shows the estimated monthly cost of the change. Reviewers see what the database costs before it merges, not on next month's AWS bill.
Infracost also scans connected repositories for previous-generation Amazon RDS r-family classes already in code. FinOps and platform teams can burn down that backlog over time, tracking issues prevented in pull requests separately from existing issues fixed.
Teams can set the policy to warn engineers or block pull requests. Limiting it to new resources keeps an unrelated pull request from forcing a database restart.
To find previous-generation r-family classes in a Terraform codebase:
To list running Amazon RDS DB instances on db.r3 or db.r4 with the AWS CLI:
If the database is managed by Terraform, change instance_class in code rather than in the console. Otherwise the next terraform apply sets the old class again.
Examples of Impact
Amazon RDS r-family upgrades pay off through headroom and right-sizing, because the per-resource code change is one attribute.
Illustrative example: an oversized reporting database. A platform team runs a MySQL reporting database on db.r4.2xlarge with low CPU use. After load testing confirms the working set fits in 32 GiB, the team moves it to db.r5.xlarge. That halves the instance cost.
Illustrative example: a fleet of service databases. A platform team finds a dozen PostgreSQL databases on db.r4.large from an old module default. Updating the default to db.r5.large adds memory and CPU headroom at the same hourly rate, applied over two maintenance windows.
(These are illustrative scenarios, not specific customer accounts.)
Considerations and Caveats
The Amazon RDS r-family upgrade is low risk, but it does restart the database.
Restart required. Changing
instance_classrestarts the Amazon RDS DB instance. Single-AZ databases are unavailable during the change.Engine version support. Older engine versions may not support db.r5. Check orderable options before planning the change.
Reservations do not transfer. Amazon RDS Reserved Instances are tied to an instance family. A db.r4 reservation keeps billing until it expires.
No direct price cut. At list price, db.r4 and db.r5 usually cost the same per hour. Dollar savings depend on downsizing or retiring old reservations.
Provider-specific. This policy targets Amazon RDS through the
awsTerraform provider. Azure and Google Cloud managed databases have different generations and attribute names.
Related Policies and Concepts
Amazon RDS - consider using latest generation instances for m family instances: the same generation upgrade for general-purpose Amazon RDS classes such as db.m3 and db.m4.
Amazon RDS - consider using latest generation instances for t family instances: the burstable-class equivalent of this policy, moving db.t2 to db.t3.
Amazon RDS - consider using Graviton instances: a related Compute-group policy for moving Amazon RDS databases to Arm-based classes such as db.r6g, which cost less per hour.
Amazon EC2 - consider using latest generation instances for r family instances: the same memory-optimized upgrade applied to EC2 instances.
Amazon ElastiCache - consider using latest generation nodes for r family nodes: the managed-cache version of this policy for cache.r node types.
Frequently Asked Questions (FAQs)
Is this policy supported in Infracost?
Yes. The Amazon RDS r-family latest generation policy is supported in Infracost and available in the free trial. Infracost flags RDS database instances that use a previous r-family instance class, such as db.r4.large, in the pull request that introduces them.
Can this policy be customized?
Yes. Teams can configure how Infracost enforces the Amazon RDS r-family latest generation policy. A finding can warn engineers or block the pull request, and the policy can be limited to new resources so an unrelated change does not force a database restart.
Does Infracost automatically fix violations?
No. Infracost reports each previous-generation Amazon RDS r-family instance class in the pull request, with the file and line to change. The team chooses the target class and applies the change during a maintenance window.
Is this policy cloud-agnostic?
No. The Amazon RDS r-family latest generation policy targets Amazon RDS through the aws Terraform provider. Azure SQL Database and Google Cloud SQL have their own machine generations, with different resource and attribute names.
Does upgrading an Amazon RDS instance class cause downtime?
Yes, usually a short outage. Changing the instance class on an Amazon RDS DB instance restarts it. Multi-AZ deployments reduce the interruption to a failover, which typically takes one to two minutes.
Is db.r5 cheaper than db.r4 on Amazon RDS?
Not at list price in most cases. In US East (N. Virginia), db.r4.large and db.r5.large have the same on-demand rate for RDS for MySQL. The Amazon RDS r-family upgrade delivers more memory and a faster processor for the same spend, which can let a team run a smaller instance class.
How often should I review Amazon RDS instance classes?
Teams running Infracost in CI/CD get an Amazon RDS r-family check on every pull request that touches an RDS instance. For existing databases, a quarterly review of instance classes is a reasonable cadence for most teams.
Create Free Account
This policy is supported in Infracost and available in the free trial. Sign up today and scan your code using our entire library of FinOps policies.