Skip to content

Terraform module which deploys AWS Budgets alerts to your AWS account

Notifications You must be signed in to change notification settings

sculley/terraform-aws-budgets-alerts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

terraform-aws-budgets-alerts

Terraform module which deploys AWS Budgets alerts to your AWS account using the Terraform AWS Provider Budgets resource

Description

This Terraform module deploys an AWS Budget alert to send a notification if the actual or forecasted cost has reached a certain limit within a AWS account. You can specify to choose to create an alert for the overall cost of the account or from one of the allowed services;

  • Amazon Elastic Compute Cloud - Compute
  • Amazon Redshift
  • Amazon Relational Database Service
  • Amazon ElastiCache
  • Amazon Elasticsearch Service

AWS Budgets use the cost visualisation provided by Cost Explorer to show you the status of your budgets, to provide forecasts of your estimated costs, and to track your AWS usage, including your free tier usage.

How to use

To create an overall cost alert of the AWS account we need to specify the overall_budget_cost_alert_enabled variable as true to the module, this will create an AWS Budget alert that will alert when the specified budget limit amount is reached and send an email notification to the email addresses specified.

provider "aws" {
  region = "eu-west-2"

  #access_key = "add if not .aws/credentials or env variables"
  #secret_key = "add if not .aws/credentials or env variables"
}

module "budgets-alerts" {
  source  = "sculley/budgets-alerts/aws"
  version = "1.0.2"

  overall_budget_cost_alert_enabled = true
  budget_limit_amount               = "500"
  notification_type                 = "ACTUAL"
  notification_emails               = "[email protected]"
}

You can add a AWS Budget alert for a specific service (from one of the allowed services) by setting the service_budget_cost_alert_enabled variable to true such as RDS like so;

provider "aws" {
  region = "eu-west-2"

  #access_key = "fill if not .aws/credentials or env variables"
  #secret_key = "fill if not .aws/credentials or env variables"
}

module "budgets-alerts" {
  source  = "sculley/budgets-alerts/aws"
  version = "1.0.2"

  service_budget_cost_alert_enabled = true
  budget_limit_amount               = "500"
  budget_service_filter             = "Amazon Relational Database Service"
  notification_type                 = "ACTUAL"
  notification_emails               = "[email protected]"
}

Run terraform init

$ terraform init

Run terraform plan

$ terraform plan

Apply the Terraform configuration

$ terraform apply

Requirements

Name Version
terraform >= 0.13.0
aws >= 3.52.0
random 3.3.2

Providers

Name Version
aws >= 3.52.0
random 3.3.2

Modules

No modules.

Resources

Name Type
aws_budgets_budget.overall_budget_cost_email_notification resource
aws_budgets_budget.service_budget_cost_email_notification resource
random_string.random resource

Inputs

Name Description Type Default Required
budget_limit_amount The amount for the budget alert. string "100" no
budget_limit_unit The currency used for the budget, such as USD or GB. string "USD" no
budget_service_filter An AWS Service filter to use when creating a specific service budget alert. string "Amazon Elastic Compute Cloud - Compute" no
budget_time_unit The length of time until a budget resets the actual and forecasted spend, Valid values: MONTHLY, QUARTERLY, ANNUALLY. string "MONTHLY" no
cost_type_include_credit A boolean value whether to include credits in the cost budget. string "true" no
cost_type_include_discount Specifies whether a budget includes discounts. string "true" no
cost_type_include_other_subscription A boolean value whether to include other subscription costs in the cost budget. string "true" no
cost_type_include_recurring A boolean value whether to include recurring costs in the cost budget. string "true" no
cost_type_include_refund A boolean value whether to include refunds in the cost budget. string "true" no
cost_type_include_subscription A boolean value whether to include subscriptions in the cost budget. string "true" no
cost_type_include_support A boolean value whether to include support costs in the cost budget. string "true" no
cost_type_include_tax A boolean value whether to include support costs in the cost budget. string "true" no
cost_type_include_upfront A boolean value whether to include support costs in the cost budget. string "true" no
cost_type_use_amortized Specifies whether a budget uses the amortized rate. string "false" no
cost_type_use_blended A boolean value whether to use blended costs in the cost budget. string "false" no
notification_emails List of email addresses to send budget notifications too string "" no
notification_threshold Threshold when the notification should be sent string 100 no
notification_type What kind of budget value to notify on. Can be ACTUAL or FORECASTED string "FORECASTED" no
overall_budget_cost_alert_enabled Enable/Disable the overall budget cost alert. bool false no
service_budget_cost_alert_enabled Enable/Disable a specific service budget cost alert. bool false no
service_types this is not a valid input, this map object is created to generate a shortname for the budget alert rather than using the long name for the service. map(string)
{
"Amazon ElastiCache": "elasticache",
"Amazon Elastic Compute Cloud - Compute": "ec2",
"Amazon Elasticsearch Service": "elasticsearch",
"Amazon Redshift": "redshift",
"Amazon Relational Database Service": "rds"
}
no

Outputs

No outputs.

About

Terraform module which deploys AWS Budgets alerts to your AWS account

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages