Agent Wranglers

INF-53Required

Give every account a budget with alerts

Create a monthly budget in code for every account. Alert the owning team when the forecast passes 80 percent and when spending passes 100 percent.

How to do it

Create the budget in the account baseline, so no account starts without one. Send alerts to a team channel or group address, never one person. Turn on the provider's cost anomaly detection for jumps inside the month, such as AWS Cost Anomaly Detection. On sandbox and preview accounts, add an action that stops spending when the budget runs out.

Examples

Terraform example

resource "aws_budgets_budget" "monthly" {
  name         = "shop-production-monthly"
  budget_type  = "COST"
  limit_amount = "2000"
  limit_unit   = "USD"
  time_unit    = "MONTHLY"

  notification {
    comparison_operator       = "GREATER_THAN"
    threshold                 = 80
    threshold_type            = "PERCENTAGE"
    notification_type         = "FORECASTED"
    subscriber_sns_topic_arns = [aws_sns_topic.cost_alerts.arn]
  }

  notification {
    comparison_operator       = "GREATER_THAN"
    threshold                 = 100
    threshold_type            = "PERCENTAGE"
    notification_type         = "ACTUAL"
    subscriber_sns_topic_arns = [aws_sns_topic.cost_alerts.arn]
  }
}

How to check

Every account in the organization has a budget with both alerts and is covered by a cost anomaly monitor. A test alert reaches the team channel.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/infrastructure/cost-and-ownership/budgets-for-every-account">Agent Wranglers infrastructure and environments playbook</a>. In code you write, add a comment next to it with the same link.