TheArchitect

Aurora Serverless v2 (auto-scaling DB)

AWS architecture template · Aurora Serverless v2 scales from 0.5 to 128 ACUs in seconds. Ideal for dev/test, spiky workloads, or multi-tenant apps. No idle cost at minimum capacity.

Aurora Serverless v2 (auto-scaling DB) is a free AWS architecture template built with Aurora, CloudWatch, IAM, Lambda and Secrets Manager. Open it in TheArchitect to edit the diagram, estimate monthly cost, and export the CloudFormation or Terraform that deploys it.

Aurora Serverl…DB CredentialsLambda AppLambda RoleACU Ceiling Al…
Aurora Serverless v2 (auto-scaling DB) architecture diagram

AWS services in this template

  • Aurora
  • CloudWatch
  • IAM
  • Lambda
  • Secrets Manager

Deployment notes

Needs input

  • Set MasterUserPassword via Secrets Manager before deploying.
  • MinCapacity: 0.5 ACU (~$0.06/hr minimum when active). Set to 0 for true scale-to-zero (requires Aurora MySQL 3.x / PostgreSQL 15.x).
  • Cost vs provisioned: db.t4g.medium ~$55/mo always-on. Serverless at 0.5 ACU minimum ~$22/mo if used 12 hrs/day.

Generated CloudFormation — 5 resources

Logical IDResource type
AuroraServerlessv2auroraAWS::RDS::DBCluster
DBCredentialssecretsmanagerAWS::SecretsManager::Secret
LambdaApplambdaAWS::Lambda::Function
LambdaRoleiamAWS::IAM::Role
ACUCeilingAlarmcloudwatchAWS::CloudWatch::Alarm
View the full CloudFormation template
{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "Generated by TheArchitect — https://www.thecloudarchitect.dev",
  "Metadata": {
    "TheArchitect": {
      "Edges": [
        {
          "From": "LambdaRoleiam",
          "To": "LambdaApplambda",
          "Label": "execution role"
        }
      ]
    }
  },
  "Resources": {
    "AuroraServerlessv2aurora": {
      "Type": "AWS::RDS::DBCluster",
      "Properties": {
        "DBClusterIdentifier": "cost-aurora-serverless",
        "Engine": "aurora-postgresql",
        "EngineVersion": "15.4",
        "DatabaseName": "appdb",
        "StorageEncrypted": true,
        "BackupRetentionPeriod": 7,
        "EnableHttpEndpoint": true,
        "ServerlessV2ScalingConfiguration": {
          "MinCapacity": 0.5,
          "MaxCapacity": 8
        }
      }
    },
    "DBCredentialssecretsmanager": {
      "Type": "AWS::SecretsManager::Secret",
      "Properties": {
        "Name": "cost-aurora-credentials",
        "Description": "Aurora master credentials — auto-rotated every 30 days via SecretsManager rotation Lambda"
      }
    },
    "LambdaApplambda": {
      "Type": "AWS::Lambda::Function",
      "DependsOn": [
        "LambdaRoleiam"
      ],
      "Properties": {
        "FunctionName": "cost-aurora-app",
        "Runtime": "nodejs20.x",
        "Handler": "index.handler",
        "MemorySize": 256,
        "Architectures": [
          "arm64"
        ],
        "Timeout": 30,
        "Description": "App handler — uses Aurora Data API (HTTP) to query without managing connection pools.",
        "Environment": {
          "Variables": {
            "APP_ENV": "demo",
            "LOG_LEVEL": "info"
          }
        },
        "TracingConfig": {
          "Mode": "Active"
        },
        "Code": {
          "ZipFile": "exports.handler = async (event) => ({ statusCode: 200, body: JSON.stringify({ ok: true, requestId: event.requestContext?.requestId || 'demo' }) });"
        },
        "Role": {
          "Fn::GetAtt": [
            "LambdaRoleiam",
            "Arn"
          ]
        }
      }
    },
    "LambdaRoleiam": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "RoleName": "cost-aurora-app-role",
        "Description": "Lambda execution role — RDS Data API execute + Secrets Manager read",
        "AssumeRolePolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Principal": {
                "Service": "lambda.amazonaws.com"
              },
              "Action": "sts:AssumeRole"
            }
          ]
        },
        "ManagedPolicyArns": [
          "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
        ]
      }
    },
    "ACUCeilingAlarmcloudwatch": {
      "Type": "AWS::CloudWatch::Alarm",
      "Properties": {
        "AlarmName": "cost-aurora-serverless-acu",
        "AlarmDescription": "Alert when ACU capacity approaches MaxCapacity — consider raising the ceiling or optimising queries",
        "Namespace": "AWS/RDS",
        "MetricName": "ServerlessDatabaseCapacity",
        "Statistic": "Maximum",
        "Period": 300,
        "EvaluationPeriods": 3,
        "Threshold": 7,
        "ComparisonOperator": "GreaterThanOrEqualToThreshold",
        "TreatMissingData": "notBreaching"
      }
    }
  }
}

Generated by TheArchitect from the diagram above. Review values such as names, CIDR ranges and instance sizes before deploying to your account.

Related templates