Did you know you can define AWS budgets in Terraform?


Did you know you can define AWS budgets in Terraform?

Did you know you can define AWS Budgets in Terraform?

resource "aws_budgets_budget" "ec2" {
  name              = "budget-ecs-monthly"
  budget_type       = "COST"
  limit_amount      = "120"
  limit_unit        = "USD"
  time_period_end   = "2087-06-15_00:00"
  time_period_start = "2017-07-01_00:00"
  time_unit         = "MONTHLY"

  cost_filter {
    name = "Service"
    values = [
      "Amazon Elastic Compute Cloud - Compute",
    ]
  }

  notification {
    comparison_operator        = "GREATER_THAN"
    threshold                  = 100
    threshold_type             = "PERCENTAGE"
    notification_type          = "FORECASTED"
    subscriber_email_addresses = ["mlea@schematical.com"]
  }

  tags = {
    Tag1 = "Value1"
    Tag2 = "Value2"
  }
}

With me launching Cloud War Games I need to make sure I am not spending too much on the sandbox infrastructure so I started digging in on AWS Budgets and Actions and I was pleasantly surprised we could manage all of that with Terraform.

Something to add to your tool chest.

How are you managing your AWS budget?