Skip to content

Instantly share code, notes, and snippets.

@Pelirrojo
Last active September 20, 2025 21:52
Show Gist options
  • Save Pelirrojo/e175230cdbdd1205f58f0cd98fcab42b to your computer and use it in GitHub Desktop.
Save Pelirrojo/e175230cdbdd1205f58f0cd98fcab42b to your computer and use it in GitHub Desktop.

Revisions

  1. Pelirrojo revised this gist Sep 20, 2025. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions budgets.tf
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    #
    # Budgets & Limits for AWS Bedrock
    # https://github.com/evereven-tech/horizons-omnichat/blob/main/aws/13-budgets.tf
    # #############################################################################

    terraform {
  2. Pelirrojo created this gist Sep 20, 2025.
    110 changes: 110 additions & 0 deletions budgets.tf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,110 @@
    #
    # Budgets & Limits for AWS Bedrock
    # #############################################################################

    terraform {
    required_version = "~> 1.10.5"

    required_providers {
    aws = {
    source = "hashicorp/aws"
    version = "6.11.0"
    }
    }

    backend "s3" {}
    }

    # Variables

    variable "budget_notification_emails" {
    description = "Email addresses for budget notifications"
    type = list(string)
    }

    variable "budget_notification_thresholds" {
    description = "Budget notification thresholds"
    type = list(number)
    }

    variable "platform_budget_limit" {
    description = "Platform budget limit"
    type = string
    }

    variable "marketplace_budget_limit" {
    description = "Marketplace budget limit"
    type = string
    }

    # Resources

    resource "aws_budgets_budget" "platform_cost" {
    name = "Platform-Cost-Budget"
    budget_type = "COST"
    time_unit = "MONTHLY"
    limit_amount = var.platform_budget_limit
    limit_unit = "USD"

    cost_filter {
    name = "BillingEntity"
    values = ["AWS"]
    }

    dynamic "notification" {
    for_each = var.budget_notification_thresholds
    content {
    comparison_operator = "GREATER_THAN"
    threshold_type = "PERCENTAGE"
    notification_type = "ACTUAL"
    threshold = notification.value
    subscriber_email_addresses = var.budget_notification_emails
    }
    }

    dynamic "notification" {
    for_each = var.budget_notification_thresholds
    content {
    comparison_operator = "GREATER_THAN"
    threshold_type = "PERCENTAGE"
    notification_type = "FORECASTED"
    threshold = notification.value
    subscriber_email_addresses = var.budget_notification_emails
    }
    }
    }

    resource "aws_budgets_budget" "marketplace_cost" {
    name = "Marketplace-External-Models-Budget"
    budget_type = "COST"
    time_unit = "MONTHLY"
    limit_amount = var.marketplace_budget_limit
    limit_unit = "USD"

    cost_filter {
    name = "BillingEntity"
    values = ["AWS Marketplace"]
    }

    dynamic "notification" {
    for_each = var.budget_notification_thresholds
    content {
    comparison_operator = "GREATER_THAN"
    threshold_type = "PERCENTAGE"
    notification_type = "ACTUAL"
    threshold = notification.value
    subscriber_email_addresses = var.budget_notification_emails
    }
    }

    dynamic "notification" {
    for_each = var.budget_notification_thresholds
    content {
    comparison_operator = "GREATER_THAN"
    threshold_type = "PERCENTAGE"
    notification_type = "FORECASTED"
    threshold = notification.value
    subscriber_email_addresses = var.budget_notification_emails
    }
    }
    }