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. ๐ฐ
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.
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 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 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.
โ
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.
-
Open your terminal or command prompt.
-
Navigate to the directory where you'd like to place the project:
cd /path/to/your/directory
-
Clone the repository:
git clone https://github.com/NotHarshhaa/aws-billing-alert-terraform.git
-
Move into the directory:
cd aws-billing-alert-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
Prepare Terraform for use:
terraform init
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
terraform apply
Modify the alert_thresholds
in your variables file to configure additional thresholds for your billing alerts:
alert_thresholds = [100, 150, 200, 250]
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.
This module supports email alerts via AWS SNS. Update the email_endpoints
variable with your preferred email addresses to receive billing notifications.
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"
}
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
.
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.
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!
Tip
Join Our Telegram Community || Follow me on GitHub for more DevOps content!