Skip to content
This repository was archived by the owner on Mar 30, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions aws/terraform/cloud-financial-management/budget-alert/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Budget Alert
This building block will set up a budget alert for your account. You can easily define an amount, threshold, and the alert receiver emails to keep an eye on you cost.

## Requirements
- You need a user with at least "AWSBudgetsActionsWithAWSResourceControlAccess" permission.
- "Access Key ID" and "Secret Access Key" for the authentication of the terraform provider
- Terraform backend file (see the next section)

## Backend configuration
Here you can find an example of how to create a backend.tf file on this [Wiki Page](https://github.com/meshcloud/building-blocks/wiki/%5BUser-Guide%5D-Setting-up-the-Backend-for-terraform-state#how-to-configure-backendtf-file-for-these-providers)
24 changes: 24 additions & 0 deletions aws/terraform/cloud-financial-management/budget-alert/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
resource "aws_budgets_budget" "monthly" {
name = "budget-monthly"
budget_type = "COST"
limit_amount = var.amount
limit_unit = "USD"
time_period_end = "2087-06-15_00:00"
time_period_start = "2017-07-01_00:00"
time_unit = "MONTHLY"

notification {
comparison_operator = "GREATER_THAN"
threshold = var.actual_threshold
threshold_type = "PERCENTAGE"
notification_type = "ACTUAL" # ACTUAL or FORECASTED
subscriber_email_addresses = var.contact_email
}
notification {
comparison_operator = "GREATER_THAN"
threshold = var.forecasted_threshold
threshold_type = "PERCENTAGE"
notification_type = "ACTUAL" # ACTUAL or FORECASTED
subscriber_email_addresses = var.contact_email
}
}
15 changes: 15 additions & 0 deletions aws/terraform/cloud-financial-management/budget-alert/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "budget_ARN" {
value = aws_budgets_budget.monthly.arn
}

output "budget_amount" {
value = aws_budgets_budget.monthly.limit_amount
}

output "budget_unit" {
value = aws_budgets_budget.monthly.limit_unit
}

output "budget_notification" {
value = aws_budgets_budget.monthly.notification
}
15 changes: 15 additions & 0 deletions aws/terraform/cloud-financial-management/budget-alert/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.31.0"
}
}
}

provider "aws" {
# Configuration options
}

19 changes: 19 additions & 0 deletions aws/terraform/cloud-financial-management/budget-alert/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
variable "amount" {
type = string
description = "The amount of monthly budget in USD"
}

variable "actual_threshold" {
type = string
description = "The actual threshold to trigger the alert when it's reached"
}

variable "forecasted_threshold" {
type = string
description = "The forecasted threshold to trigger the alert when it's reached"
}

variable "contact_email" {
type = list(string)
description = "list of emails which should receive the budget alerts. e.g. ['devops@example.com']"
}