Setting Up Budget Alerts

Prerequisites

  • AWS account with appropriate permissions
  • Terraform >= 1.0
  • Email addresses for notifications

Step 1: Create the Budget

module "production_budget" {
  source  = "registry.patterneddesigns.ca/governance/cost-controls/aws"
  version = "1.2.0"

  budget_name  = "production-monthly-budget"
  budget_limit = 5000

  alert_thresholds = [50, 75, 90, 100]

  notification_emails = [
    "finance@example.com",
    "cloud-ops@example.com"
  ]
}

Step 2: Add SNS Integration

Configure an SNS topic for additional notification channels.

resource "aws_sns_topic" "budget_alerts" {
  name = "budget-alerts"
}

resource "aws_sns_topic_policy" "budget_alerts" {
  arn = aws_sns_topic.budget_alerts.arn

  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [{
      Effect    = "Allow"
      Principal = { Service = "budgets.amazonaws.com" }
      Action    = "SNS:Publish"
      Resource  = aws_sns_topic.budget_alerts.arn
    }]
  })
}

module "production_budget" {
  source  = "registry.patterneddesigns.ca/governance/cost-controls/aws"
  version = "1.2.0"

  budget_name   = "production-monthly-budget"
  budget_limit  = 5000
  sns_topic_arn = aws_sns_topic.budget_alerts.arn

  alert_thresholds    = [50, 75, 90, 100]
  notification_emails = ["finance@example.com"]
}

Step 3: Deploy and Verify

Run terraform apply and verify the budget in the AWS Console.

terraform init
terraform plan
terraform apply

Step 4: Test Alerts

Use the AWS CLI to verify the budget was created:

aws budgets describe-budgets --account-id $(aws sts get-caller-identity --query Account --output text)