CostHex

AWS Lambda billing alarms and spend controls

Use AWS Budgets for Lambda dollar alerts and CloudWatch for unusual function activity. To restrict execution, configure reserved concurrency. Billing alerts are delayed, and a concurrency limit does not guarantee a maximum monthly bill. Choose an alert recipient and record who can throttle the function.

Set a Lambda cost budget

  1. Open Billing and Cost Management → Budgets → Create budget. Choose Customize (advanced) → Cost budget.
  2. Name the budget. Choose a recurring monthly period and a fixed amount.
  3. Under Budget scope → Filters → Add filter, use the Service filter to select AWS Lambda. Check the resulting scope before continuing.
  4. Add alert thresholds for Actual spending, Forecasted spending, or both. Enter email recipients or an SNS topic.
  5. Review the settings and create the budget. Complete the email verification or SNS subscription confirmation requested by AWS.

These steps follow AWS's cost-budget procedure and service-filter documentation. A Lambda-only budget excludes services your function calls. Add an account-wide budget to watch those costs too.

AWS Budgets updates up to three times daily, typically 8–12 hours apart. Billing delays can let charges pass your threshold before a notification arrives. Choose a threshold below the amount you can afford to lose.

If you want a CloudWatch dollar alarm

A CloudWatch billing alarm watches estimated charges already incurred, rather than a forecast. Billing metrics represent worldwide charges but live in US East (N. Virginia), us-east-1.

  1. In Billing Preferences, enable Receive CloudWatch Billing Alerts. For consolidated billing, the payer account must enable it.
  2. Switch CloudWatch to us-east-1. Open Alarms → All alarms → Create alarm → Select metric → Billing → Total Estimated Charge.
  3. Select EstimatedCharges, Maximum, and a 6-hour period. Choose a static threshold above which to notify you.
  4. Use one breaching datapoint out of one, treat missing data as missing, and choose an SNS topic for the alarm notification. Name and create the alarm.

This is an account-total alarm. Estimated billing data updates several times daily; a short evaluation period cannot make that data arrive sooner.

Add a function activity alarm

Use Lambda metrics to watch executions separately from dollars: Invocations with Sum for executed calls, and ConcurrentExecutions with Maximum for simultaneous work. Throttled requests do not count as Invocations.

  1. In the function's Region, create a CloudWatch alarm. Select the AWS/Lambda namespace, By Function Name, and the function's Invocations metric.
  2. Choose Sum and a period that matches your traffic pattern. Set a threshold above your expected calls in that period.
  3. Configure evaluation periods and missing-data handling. Select an SNS notification, then name, review and create the alarm.

The function dimension combines versions and aliases. Follow AWS's alarm procedure to adjust its conditions. Metrics can arrive after a long invocation finishes; this is an activity signal, not a dollar-limit guarantee.

Limit execution and prepare a stop procedure

For reserved concurrency, open the Lambda function's Configuration → Concurrency → Edit → Reserve concurrency, enter a limit and save. This limits simultaneous execution. A low limit can throttle legitimate requests.

AWS documents reserved concurrency of zero as a way to stop the function processing events until you remove the limit. Before using it during an incident, decide how to handle queued work and restore the original setting. It does not stop other functions or services.

Budget actions are configured separately from notifications. Their documented controls include IAM/SCP policies and targeting EC2 or RDS instances. Creating a budget email does not configure a Lambda shutdown.

Keep an account-wide view: a function can lead to storage, queue or other service charges. The sourced S3 empty-bucket bill account covers request costs outside Lambda. For another platform, see Google Cloud's budget controls.

Official sources