Skip to content

osgurisdosre/terraform-aws-budget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform modules Budgets

This module seeks to create a Budget for the AWS account, accepting 1 or more alerts, we chose to use email notifications, in view of the practicality.

Below 2 examples of how to use the module, 1 with Terraform another with Terragrunt:

Terragrunt

name: "budget-aws"
budget_type : "COST"
time_unit   : "MONTHLY"
limit_unit  : "USD"
limit_amount: "1000"
time_period_start: "2022-10-01_00:00"
notification: 
  -  comparison_operator        : "GREATER_THAN"
     threshold                  : 100
     threshold_type             : "PERCENTAGE"
     notification_type          : "FORECASTED"
     subscriber_email_addresses : "[email protected]"
  -
    comparison_operator        : "GREATER_THAN"
    threshold                  : 90
    threshold_type             : "PERCENTAGE"
    notification_type          : "FORECASTED"
    subscriber_email_addresses :
      - "[email protected]"
      - "[email protected]"

Terraform

module "budget" {
  source                     = "osgurisdosre/budget/aws"
  name                       = var.name
  budget_type                = var.budget_type["budget_type"]
  limit_amount               = var.limit_amount
  limit_unit                 = var.limit_unit
  time_period_start          = var.time_period_start
  time_unit                  = var.time_unit
  #Accepts various notifications, just add or remove blocks {}
  notification = [
  { 
    comparison_operator = "GREATER_THAN",
    threshold = 100,
    threshold_type = "PERCENTAGE",
    notification_type = "FORECASTED",
    subscriber_email_addresses = ["[email protected]", "[email protected]"]
  },
  { 
    comparison_operator = "GREATER_THAN",
    threshold = 97,
    threshold_type = "PERCENTAGE",
    notification_type = "FORECASTED",
    subscriber_email_addresses = ["[email protected]", "[email protected]"]
  }
  ]
}

Requirements

Name Version
terraform >= 1.3
aws >= 4.48

Providers

Name Version
aws >= 4.48

Modules

No modules.

Resources

Name Type
aws_budgets_budget.budget resource

Inputs

Name Description Type Default Required
budget_type Whether this budget tracks monetary cost or usage. string "COST" no
cost_filter A list of CostFilter name/values pair to apply to budget. list(map(string)) [] no
cost_types Whether this budget tracks monetary cost or usage.
list(object({
include_discount = optional(bool)
include_other_subscription = optional(bool)
include_recurring = optional(bool)
include_refund = optional(bool)
include_subscription = optional(bool)
include_support = optional(bool)
include_tax = optional(bool)
use_amortized = optional(bool)
include_upfront = optional(bool)
use_blended = optional(bool)
include_credit = optional(bool)
}))
[
{
"include_credit": true,
"include_discount": true,
"include_other_subscription": true,
"include_recurring": true,
"include_refund": true,
"include_subscription": true,
"include_support": true,
"include_tax": true,
"include_upfront": true,
"use_amortized": false,
"use_blended": false
}
]
no
limit_amount The name of a budget. Unique within accounts. number n/a yes
limit_unit The unit of measurement used for the budget forecast, actual spend, or budget threshold, such as dollars or GB. string "USD" no
name The name of a budget. Unique within accounts. string n/a yes
notification list of values to notification
list(object({
comparison_operator = string
threshold = number
threshold_type = string
notification_type = string
subscriber_email_addresses = optional(list(string))
subscriber_sns_topic_arns = optional(list(string))
}))
n/a yes
time_period_end The unit of measurement used for the budget forecast, actual spend, or budget threshold, such as dollars or GB. string "2087-06-15_00:00" no
time_period_start The start of the time period covered by the budget. If you don't specify a start date, AWS defaults to the start of your chosen time period. The start date must come before the end date. Format: 2017-01-01_12:00. string null no
time_unit ) The length of time until a budget resets the actual and forecasted spend. Valid values: MONTHLY, QUARTERLY, ANNUALLY, and DAILY. string "MONTHLY" no

Outputs

Name Description
budget_name The name of the Budget.

Authors

Module is maintained by Emidio Neto, Leonardo Jardim and Yuri Azeredo

License

Apache 2 Licensed. See LICENSE for full details.