cost-controls

Category Governance
Latest Version 0.1.0current

Terraform module for cost-controls on aws

Add to your Terraform configuration
module "cost_controls" {
  source  = "registry.patterneddesigns.ca/governance/cost-controls/aws"
  version = "0.1.0"

  # Required inputs
  budget_name = "..."
  budget_limit = "..."
}

Overview

The cost-controls module implements AWS cost governance through budgets, alerts, and spending limits including:

  • Automatic budget creation with AWS Budgets service
  • Multi-threshold alerts at configurable spending percentages
  • Email and SNS notification integration
  • Support for cost and usage budget types
  • Tag-based budget filtering for granular control

Category: Governance Provider: AWS Latest Version: 1.2.0

Quick Start

module "budget" {
  source  = "registry.patterneddesigns.ca/governance/cost-controls/aws"
  version = "1.2.0"

  budget_name  = "monthly-spend-limit"
  budget_limit = 5000

  alert_thresholds = [50, 75, 90, 100]

  notification_emails = [
    "finance@example.com",
    "cloud-ops@example.com"
  ]
}

Key Features

Multi-Threshold Alerts

Configure alerts at multiple spending thresholds to catch cost overruns early:

module "budget" {
  source  = "registry.patterneddesigns.ca/governance/cost-controls/aws"
  version = "1.2.0"

  budget_name  = "production-budget"
  budget_limit = 10000

  alert_thresholds = [25, 50, 75, 90, 100, 110]

  notification_emails = ["finance@example.com"]
}

SNS Integration

Connect to existing notification workflows with SNS topics:

module "budget" {
  source  = "registry.patterneddesigns.ca/governance/cost-controls/aws"
  version = "1.2.0"

  budget_name  = "ops-budget"
  budget_limit = 3000

  alert_thresholds    = [80, 100]
  notification_emails = ["ops@example.com"]

  sns_topic_arn = aws_sns_topic.alerts.arn
}

Service-Specific Budgets

Create budgets filtered to specific AWS services:

module "ec2_budget" {
  source  = "registry.patterneddesigns.ca/governance/cost-controls/aws"
  version = "1.2.0"

  budget_name  = "ec2-compute-budget"
  budget_limit = 2000

  alert_thresholds    = [75, 100]
  notification_emails = ["infra@example.com"]

  cost_filters = {
    Service = ["Amazon Elastic Compute Cloud - Compute"]
  }
}

Documentation

Registry

View specification on Registry

Inputs

budget_name Required
string

Name for the AWS Budget. Must be unique within your AWS account. Can contain alphanumeric characters, hyphens, underscores, and periods. Maximum 100 characters.

budget_limit Required
number

Monthly budget limit in USD. Sets the maximum expected spend for the budget period and is used as the baseline for calculating alert thresholds.

list(number) Default: [50, 80, 100]

Percentage thresholds for budget alerts. Multiple thresholds provide early warning as spending increases. Common patterns: conservative [25, 50, 75, 90, 100], standard [50, 80, 100], aggressive [80, 100, 110].

Email addresses for budget notifications. AWS Budgets will send emails directly to these addresses when thresholds are exceeded. Use team distribution lists rather than individual emails.

ARN of SNS topic for budget notifications. Allows budget alerts to be published to an existing SNS topic for integration with other notification workflows, automation, and third-party tools. Set to null to skip SNS integration.

Outputs

budget_arn

ARN of the created AWS Budget. Use this for IAM policies and resource references.

sns_topic_arn

ARN of the SNS topic used for budget notifications. Available when the module creates its own SNS topic or when an existing topic is provided.

budget_name

Name of the created AWS Budget as created in the AWS account. Use this for API calls and CLI commands.