Lesson 4 of 4 ยท AWS with Terraform
Databases and serverless
Managed databases reduce operational work but still need network, backup, and access decisions. Lambda runs small event-driven workloads without managing servers. Both need explicit permissions and realistic usage assumptions.
Example
resource "aws_db_instance" "app" {
engine = "postgres"
instance_class = "db.t3.micro"
allocated_storage = 20
}Step by step
- Keep databases reachable only from the workloads that need them.
- Set backup and retention expectations.
- Use serverless functions for focused event-driven tasks.
- Review cost assumptions for requests and storage.
Common mistakes to avoid
- Publishing a database endpoint unnecessarily.
- Treating Lambda as free without considering invocations and duration.