Skip to content

Repository files navigation

Appvia Banner

Terraform Registry Latest Release Slack Community Contributors

Github Actions

Terraform AWS Budgets

Introduction

This module standardizes AWS Budget creation for account and workload cost controls, with built-in support for email and SNS notifications. It is designed as a single root module so teams can adopt a consistent budget pattern without composing multiple nested modules.

Features

  • Multi-budget provisioning in one module invocation
  • Cost and usage budget support with per-budget filters and cost types
  • Notification fanout to email and SNS endpoints
  • SNS notification target can be configured by full ARN or by topic name
  • Tagging support for organizational governance and reporting

Usage

Golden Path

module "budgets" {
  source = "appvia/budgets/aws"

  budgets = [
    {
      name         = "monthly-spend"
      budget_type  = "COST"
      limit_amount = "1000"
      limit_unit   = "USD"
      time_unit    = "MONTHLY"
      notifications = {
        actual = {
          comparison_operator = "GREATER_THAN"
          threshold           = 80
          threshold_type      = "PERCENTAGE"
          notification_type   = "ACTUAL"
        }
      }
    }
  ]

  notifications = {
    email = {
      addresses = ["platform@example.com"]
    }
  }

  tags = {
    Environment = "production"
    ManagedBy   = "terraform"
  }
}

Power User

module "budgets" {
  source = "appvia/budgets/aws"

  budgets = [
    {
      name         = "eu-west-2-forecast"
      budget_type  = "COST"
      limit_amount = "2500"
      limit_unit   = "USD"
      time_unit    = "MONTHLY"
      cost_filter = {
        Region = {
          values = ["eu-west-2"]
        }
      }
      cost_types = {
        include_credit       = false
        include_discount     = false
        include_recurring    = true
        include_refund       = false
        include_subscription = true
        include_support      = true
        include_tax          = true
        include_upfront      = true
        use_blended          = false
      }
      notifications = {
        forecast = {
          comparison_operator = "GREATER_THAN"
          threshold           = 90
          threshold_type      = "PERCENTAGE"
          notification_type   = "FORECASTED"
        }
      }
      tags = {
        CostCenter = "engineering"
      }
    }
  ]

  notifications = {
    sns = {
      topic_arn = "arn:aws:sns:eu-west-2:123456789012:budget-alerts"
    }
  }

  tags = {
    Environment = "production"
    ManagedBy   = "terraform"
    Owner       = "platform"
  }
}

SNS Topic Name Alternative

module "budgets" {
  source = "appvia/budgets/aws"

  budgets = [
    {
      name         = "monthly-spend"
      budget_type  = "COST"
      limit_amount = "1000"
      limit_unit   = "USD"
      time_unit    = "MONTHLY"
      notifications = {
        actual = {
          comparison_operator = "GREATER_THAN"
          threshold           = 80
          threshold_type      = "PERCENTAGE"
          notification_type   = "ACTUAL"
        }
      }
    }
  ]

  notifications = {
    sns = {
      topic_name = "budget-alerts"
    }
  }

  tags = {
    Environment = "production"
    ManagedBy   = "terraform"
  }
}

Migration

  • modules/budgets has been moved to the repository root; update module sources from ...//modules/budgets to appvia/budgets/aws.
  • modules/team-budgets has been removed and is no longer supported.

Update Documentation

The terraform-docs utility is used to generate this README. Follow the below steps to update:

  1. Make changes to the .terraform-docs.yml file
  2. Fetch the terraform-docs binary (https://terraform-docs.io/user-guide/installation/)
  3. Run terraform-docs markdown table --output-file ${PWD}/README.md --output-mode inject .

Providers

Name Version
aws >= 6.0.0

Inputs

Name Description Type Default Required
notifications The configuration as to how the budget notifications should be sent
object({
# Configuration for the email notifications. If null, email notifications will not be sent.
email = optional(object({
# List of email addresses to send the notifications to.
addresses = list(string)
}), null)
# COnfiguration for the SNS notifications. If null, SNS notifications will not be sent.
sns = optional(object({
# The ARN for the queue to send the notifications to.
topic_arn = optional(string, null)
# The name of a SNS topic to send the notifications to.
topic_name = optional(string, null)
}), null)
})
n/a yes
tags A map of tags to add to all resources map(string) n/a yes
budgets A collection of budgets to provision
list(object({
auto_adjust_data = optional(list(object({
auto_adjust_type = string
})), [])
budget_type = optional(string, "COST")
cost_filter = optional(map(object({
values = list(string)
})), {})
cost_types = optional(object({
include_credit = optional(bool, false)
include_discount = optional(bool, false)
include_other_subscription = optional(bool, false)
include_recurring = optional(bool, false)
include_refund = optional(bool, false)
include_subscription = optional(bool, false)
include_support = optional(bool, false)
include_tax = optional(bool, false)
include_upfront = optional(bool, false)
use_blended = optional(bool, false)
}), {
include_credit = false
include_discount = false
include_other_subscription = false
include_recurring = false
include_refund = false
include_subscription = true
include_support = false
include_tax = false
include_upfront = false
use_blended = false
})
limit_amount = optional(string, "100.0")
limit_unit = optional(string, "PERCENTAGE")
name = string
notifications = optional(map(object({
comparison_operator = string
notification_type = string
threshold = number
threshold_type = string
})), {})
tags = optional(map(string), {})
time_unit = optional(string, "MONTHLY")
}))
[] no

Outputs

Name Description
budget_arns Map of budget names to budget ARNs
budget_ids Map of budget names to budget IDs
budget_names List of created budget names

About

Contains a number of modules related to cost controls and AWS budgets

Resources

Code of conduct

Security policy

Stars

0 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages