Skip to content

๐“๐ก๐ข๐ฌ ๐ซ๐ž๐ฉ๐จ๐ฌ๐ข๐ญ๐จ๐ซ๐ฒ ๐œ๐จ๐ง๐ญ๐š๐ข๐ง๐ฌ ๐š ๐“๐ž๐ซ๐ซ๐š๐Ÿ๐จ๐ซ๐ฆ ๐ฆ๐จ๐๐ฎ๐ฅ๐ž ๐ญ๐ก๐š๐ญ ๐ก๐ž๐ฅ๐ฉ๐ฌ ๐ฌ๐ž๐ญ ๐ฎ๐ฉ ๐€๐–๐’ ๐›๐ข๐ฅ๐ฅ๐ข๐ง๐  ๐š๐ฅ๐ž๐ซ๐ญ๐ฌ

Notifications You must be signed in to change notification settings

NotHarshhaa/aws-billing-alert-terraform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ AWS Billing Alert Terraform Module

AWS-billing

Welcome to the AWS Billing Alert Terraform module! This module helps you set up automatic billing alerts for your AWS account. Once configured, you'll receive notifications when your AWS charges exceed specified amounts, helping you stay on top of your costs. ๐Ÿ’ฐ


๐Ÿ› ๏ธ Prerequisites

Important

Before you begin, make sure you have the following:

  • ๐Ÿงฐ Terraform (v1.5.0 or later) installed on your local machine.
  • ๐ŸŒ An AWS account with appropriate permissions.
  • ๐Ÿ”‘ AWS CLI configured with the necessary credentials.

๐Ÿ” Understanding the AWS Services

๐ŸŒŸ AWS CloudWatch

AWS CloudWatch is a monitoring and observability service that collects and tracks metrics, collects and monitors log files, and sets alarms. This module uses CloudWatch to monitor your AWS billing and trigger an alarm when specified thresholds are exceeded.

๐Ÿ“ข AWS SNS (Simple Notification Service)

AWS SNS is a fully managed messaging service. It allows you to send notifications to multiple subscribers. In this module, SNS is used to send billing alerts via email, SMS, or other supported channels when the CloudWatch alarm is triggered.

๐Ÿงพ AWS Billing

AWS Billing provides tools to manage your AWS costs and budget. This module automates the monitoring of your AWS billing, so you're notified before your bill goes beyond your expectations.


๐Ÿš€ New Features & Improvements [07-03-2025]

โœ… Multiple Email Alerts โ€“ Supports multiple recipients by allowing a list of emails.
โœ… SNS Dead-Letter Queue (DLQ) โ€“ Ensures failed notifications are retried.
โœ… Per-Service Billing Alerts โ€“ Monitors spending on individual AWS services like EC2, S3, etc.
โœ… Enhanced CloudWatch Filters โ€“ Improved billing log monitoring for better cost visibility.
โœ… CloudWatch Dashboard โ€“ Provides an overview of billing trends and cost insights.


๐Ÿ“ฆ Setup Instructions

1๏ธโƒฃ Clone the Repository

  1. Open your terminal or command prompt.

  2. Navigate to the directory where you'd like to place the project:

    cd /path/to/your/directory  
  3. Clone the repository:

    git clone https://github.com/NotHarshhaa/aws-billing-alert-terraform.git  
  4. Move into the directory:

    cd aws-billing-alert-terraform  

2๏ธโƒฃ Install Terraform

Follow the steps in your system documentation to install Terraform or use the quick instructions for Amazon Linux:

sudo yum install -y yum-utils shadow-utils  
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo  
sudo yum -y install terraform  
terraform --version  

3๏ธโƒฃ Initialize Terraform

Prepare Terraform for use:

terraform init  

4๏ธโƒฃ Configure and Apply Changes

Update Configuration Variables:

With the recent changes, you can now:

  • Set custom AWS regions using aws_region.
  • Configure currencies for billing alerts.
  • Automatically confirm email subscriptions for ease of setup during testing.
  • Configure per-service billing alerts to track costs for specific AWS services.
  • Enable SNS DLQ for better message reliability.
  • Visualize billing trends via the CloudWatch Dashboard.

Update the terraform.tfvars file with your settings:

aws_region            = "us-east-1"  
alert_thresholds      = [100, 150, 200]  
currency              = "USD"  
email_endpoints       = ["your-email@example.com", "team@example.com"]  
auto_confirm_subscription = true  

Apply the Configuration:

terraform apply  

๐Ÿ”ง Customization

Billing Thresholds

Modify the alert_thresholds in your variables file to configure additional thresholds for your billing alerts:

alert_thresholds = [100, 150, 200, 250]  

Email Subscription Auto-Confirmation

For testing purposes, you can enable automatic email confirmation by setting:

auto_confirm_subscription = true  

Important

Use this option only in test environments with proper permissions.


๐Ÿ“ฌ Notifications

This module supports email alerts via AWS SNS. Update the email_endpoints variable with your preferred email addresses to receive billing notifications.


๐Ÿ“ Example Usage

Hereโ€™s an example configuration:

module "billing_alert" {  
  source                     = "github.com/NotHarshhaa/aws-billing-alert-terraform"  
  aws_region                 = "us-west-2"  
  alert_thresholds           = [100, 150, 200]  
  email_endpoints            = ["my-email@example.com", "finance@example.com"]  
  auto_confirm_subscription  = true  
  currency                   = "USD"  
}  

๐ŸŽฏ Usage

This module is flexible and supports dynamic region, currency, and threshold configurations. Customize the alert.tf file as needed and reapply the configuration using terraform apply.


๐Ÿ™Œ Feedback and Contributions

Tip

We'd love to hear your thoughts! Whether it's feedback, bug reports, or pull requests, feel free to get involved. Your contributions help make this module better for everyone.

โญ Hit the Star

Important

If you find this repository helpful for learning or in practice, please hit the star button on GitHub. โญ It helps others find this resource too!

๐Ÿ‘ค Author

banner

Tip

Join Our Telegram Community || Follow me on GitHub for more DevOps content!

About

๐“๐ก๐ข๐ฌ ๐ซ๐ž๐ฉ๐จ๐ฌ๐ข๐ญ๐จ๐ซ๐ฒ ๐œ๐จ๐ง๐ญ๐š๐ข๐ง๐ฌ ๐š ๐“๐ž๐ซ๐ซ๐š๐Ÿ๐จ๐ซ๐ฆ ๐ฆ๐จ๐๐ฎ๐ฅ๐ž ๐ญ๐ก๐š๐ญ ๐ก๐ž๐ฅ๐ฉ๐ฌ ๐ฌ๐ž๐ญ ๐ฎ๐ฉ ๐€๐–๐’ ๐›๐ข๐ฅ๐ฅ๐ข๐ง๐  ๐š๐ฅ๐ž๐ซ๐ญ๐ฌ

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages