Agent Wranglers

Cost and ownership Required

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. On sandbox and preview accounts, add an action that stops spending when the budget runs out.

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. A test alert reaches the team channel.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers infrastructure playbook: https://agentwranglers.se/playbook/infrastructure/cost-and-ownership/budgets-for-every-account.