aws_ db_ instance cost estimation
A managed relational database instance on RDS. Priced per hour by instance class, engine, deployment option, and region, with storage and IOPS billed separately.
An aws_
First is the instance hour rate, which depends on the instance class (db.t4g.micro through db.r6id.32xlarge), the engine (Postgres and MySQL are cheapest; SQL Server, Oracle, and license-included variants are dramatically more expensive), and whether the database is single-AZ or Multi-AZ. Multi-AZ roughly doubles the compute cost because AWS provisions a hot standby in another availability zone.
Second is storage. RDS storage is billed per GB-month, with separate rates by storage type (gp2, gp3, io1, magnetic). gp3 is the recommended default for most workloads. Multi-AZ doubles the effective storage cost since the standby keeps a copy.
Third is provisioned IOPS, which applies if you use io1 or io2 storage, or gp3 above its baseline. IOPS are billed per IOPS-month.
c3x estimates all three from the Terraform configuration. Backup storage exceeding 100% of provisioned storage is usage-based and requires a c3x-usage.yml entry to model accurately.
Terraform example
A minimal but realistic configuration that C3X can estimate.
resource "aws_db_instance" "postgres" {
identifier = "production-postgres"
engine = "postgres"
engine_version = "15.4"
instance_class = "db.r5.large"
allocated_storage = 200
storage_type = "gp3"
multi_az = true
username = "app"
password = var.db_password
backup_retention_period = 7
skip_final_snapshot = false
}Pricing dimensions
What you actually pay for when you provision aws_.
| Dimension | Unit | What's being charged |
|---|---|---|
| Database instance hours | per hour | On-demand rate for the instance class, engine, and deployment option. c3x assumes 730 hours per month for monthly estimates. $0.50/hour for db.r5.large PostgreSQL Multi-AZ in us-east-1 |
| Storage | per GB-month | Provisioned storage at the configured size. Multi-AZ doubles the effective storage cost. $0.115/GB-month for gp3 in us-east-1 (Multi-AZ) |
| Provisioned IOPS | per IOPS-month | For io1/io2 storage, or gp3 provisioned above the 3,000 baseline IOPS. |
| Backup storage | per GB-month | Backup storage exceeding 100% of provisioned storage. Define expected size in c3x-usage.yml to estimate accurately. |
| Data transfer out | per GB | Bytes egressing the AWS region. Cross-AZ replication for Multi-AZ is free. |
Sample C3X output
Example output from c3x estimate on the Terraform above:
aws_db_instance.postgres
├─ Database instance (on-demand, Multi-AZ, db.r5.large) 730 hours $365.00
└─ Storage (general purpose SSD, gp3) 200 GB $46.00
OVERALL TOTAL $411.00Optimization tips
Common ways to reduce aws_ cost without changing the workload.
Drop Multi-AZ for non-production environments
Up to 50%Multi-AZ roughly doubles instance and storage cost. For staging, dev, and ephemeral environments, single-AZ is typically sufficient and cuts the bill in half.
Switch storage from gp2 to gp3
About 20%gp3 is around 20% cheaper than gp2 at the same size and offers baseline 3,000 IOPS by default. Most RDS workloads see no performance regression on gp3.
Use Aurora Serverless v2 for variable workloads
Workload-dependentIf your database has long idle periods or unpredictable spikes, Aurora Serverless v2 scales ACUs by demand and can be cheaper than a fixed db.r5.large running 24/7.
Buy Reserved Instances for steady-state databases
30-50%Databases rarely scale up and down like compute. A 1-year all-upfront RI cuts on-demand cost by 30-50%. Model with purchaseOption: 'reserved' in c3x-usage.yml.
FAQ
Does c3x handle Multi-AZ pricing correctly?
Yes. c3x reads the multi_
How does c3x price Oracle and SQL Server?
Oracle and SQL Server have license-included pricing tiers that vary by edition (Standard, Web, Enterprise) and are significantly more expensive than Postgres or MySQL at the same instance size. c3x picks up the engine attribute and uses the correct license tier from AWS pricing.
Are backups counted in the estimate?
Backup storage up to 100% of provisioned storage is free and not counted. Anything beyond that is usage-based and only appears in the estimate if you specify expected backup size in c3x-usage.yml.
Does c3x estimate Aurora?
Aurora is aws_
Why does my estimate look high for SQL Server?
SQL Server license-included pricing can be 2-4x the cost of an equivalent Postgres instance. If the bill is a concern, consider bring-your-own-license (BYOL) on EC2 or migrating to Postgres if the application supports it.
Related resources
More AWS resources
Further reading
- AWS Graviton migration: where the ~20% savings actually come from
Graviton (ARM) instances list ~20% cheaper than x86 with up to 40% better price-performance, across EC2, Lambda, RDS, and more. Here's the discount, where it applies, and how small the migration usually is.
- The biggest AWS cost drivers: where your bill actually goes
For most AWS accounts, a short list dominates the bill: compute, data transfer, storage, databases, and managed services. Knowing which drivers matter lets you focus optimization where it pays. Here is the breakdown.
- Budget guardrails in CI: blocking PRs that exceed cost limits
Cost regressions are a category of bug that production-quality teams catch automatically. Here's how to add a budget gate to GitHub Actions, GitLab CI, Bitbucket, Atlantis, and Spacelift in five minutes.
- Connection pooling: cheap capacity you are probably wasting
Every database connection consumes memory on the server, so without pooling you scale the database up just to hold connections. A pooler like PgBouncer or RDS Proxy lets a small database serve many clients. Here is the cost-performance case.
Estimate this resource in your own Terraform
Free, open source, no API key. C3X parses your Terraform and shows line-item cost for every resource, including aws_.