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.
โ
Enhanced Security โ Added proper SNS and SQS policies for secure communication
โ
Fixed DLQ Integration โ Dead-letter queue now properly handles failed notifications
โ
Resource Dependencies โ Proper dependency management for reliable deployment
โ
Multiple Email Alerts โ Supports multiple recipients by allowing a list of emails
โ
Per-Service Billing Alerts โ Monitors spending on individual AWS services like EC2
โ
Enhanced CloudWatch Filters โ Improved billing log monitoring for better cost visibility
โ
OK Actions โ Sends recovery notifications when charges return to normal
โ
Better Code Organization โ Separated outputs and versions for maintainability
โ
Configuration Summary โ Enhanced outputs for better monitoring and debugging
-
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 Configure your billing alerts using the provided terraform.tfvars.example file:
# Copy terraform.tfvars.example to terraform.tfvars and customize
aws_region = "us-east-1"
alert_thresholds = [100, 150, 200]
currency = "USD"
email_endpoints = ["your-email@example.com", "team@example.com"]
environment_tag = "Production"
auto_confirm_subscription = false
sns_topic_name = "billing-alert" Key Features:
- ๐ Secure by Default โ Proper IAM policies and access controls
- ๐ง Multiple Recipients โ Send alerts to multiple email addresses
- ๐ Reliable Delivery โ DLQ handles failed notifications automatically
- ๐ Service Monitoring โ Separate alerts for total and EC2-specific charges
- โ Recovery Notifications โ Get alerts when charges return to normal
terraform apply 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 = false
currency = "USD"
environment_tag = "Production"
sns_topic_name = "billing-alert"
} After deployment, you'll get these useful outputs:
# SNS topic for monitoring
output "sns_topic_arn"
# List of all alarm names
output "cloudwatch_alarm_names"
output "service_alarm_names"
# DLQ for troubleshooting
output "sns_dlq_arn"
# Configuration summary
output "configuration_summary" This module is designed for simplicity and reliability:
- Quick Setup โ Copy
terraform.tfvars.exampletoterraform.tfvars - Configure Emails โ Add your email addresses to
email_endpoints - Set Thresholds โ Adjust
alert_thresholdsbased on your budget - Deploy โ Run
terraform apply - Monitor โ Receive alerts when charges exceed your thresholds
The module supports these customizations:
- Multiple thresholds โ Get alerts at different spending levels
- Service-specific monitoring โ EC2 service charges tracked separately
- Custom regions and currencies โ Deploy anywhere with local currency
- Environment tagging โ Organize resources by environment
- Least Privilege Access โ Only necessary permissions granted
- Secure Communication โ Proper SNS and SQS policies
- Resource Isolation โ Clear separation of concerns
- No Hardcoded Secrets โ All configuration via variables
Modify the alert_thresholds in your terraform.tfvars file to configure additional thresholds:
alert_thresholds = [100, 150, 200, 250]For testing purposes, you can enable automatic email confirmation by setting:
auto_confirm_subscription = trueImportant
Use this option only in test environments with proper permissions.
| Variable | Description | Default | Required |
|---|---|---|---|
aws_region |
AWS region for deployment | us-east-1 |
No |
alert_thresholds |
Billing thresholds in USD | [100, 120] |
No |
email_endpoints |
Email addresses for alerts | ['your-email@example.com'] |
Yes |
currency |
Billing currency | USD |
No |
environment_tag |
Environment tag for resources | Production |
No |
auto_confirm_subscription |
Auto-confirm email subs | false |
No |
sns_topic_name |
SNS topic name | billing-alert |
No |
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!

