https://github.com/notharshhaa/aws-billing-alert-terraform
๐๐ก๐ข๐ฌ ๐ซ๐๐ฉ๐จ๐ฌ๐ข๐ญ๐จ๐ซ๐ฒ ๐๐จ๐ง๐ญ๐๐ข๐ง๐ฌ ๐ ๐๐๐ซ๐ซ๐๐๐จ๐ซ๐ฆ ๐ฆ๐จ๐๐ฎ๐ฅ๐ ๐ญ๐ก๐๐ญ ๐ก๐๐ฅ๐ฉ๐ฌ ๐ฌ๐๐ญ ๐ฎ๐ฉ ๐๐๐ ๐๐ข๐ฅ๐ฅ๐ข๐ง๐ ๐๐ฅ๐๐ซ๐ญ๐ฌ
https://github.com/notharshhaa/aws-billing-alert-terraform
aws aws-billing aws-terraform terraform terraform-modules
Last synced: about 1 year ago
JSON representation
๐๐ก๐ข๐ฌ ๐ซ๐๐ฉ๐จ๐ฌ๐ข๐ญ๐จ๐ซ๐ฒ ๐๐จ๐ง๐ญ๐๐ข๐ง๐ฌ ๐ ๐๐๐ซ๐ซ๐๐๐จ๐ซ๐ฆ ๐ฆ๐จ๐๐ฎ๐ฅ๐ ๐ญ๐ก๐๐ญ ๐ก๐๐ฅ๐ฉ๐ฌ ๐ฌ๐๐ญ ๐ฎ๐ฉ ๐๐๐ ๐๐ข๐ฅ๐ฅ๐ข๐ง๐ ๐๐ฅ๐๐ซ๐ญ๐ฌ
- Host: GitHub
- URL: https://github.com/notharshhaa/aws-billing-alert-terraform
- Owner: NotHarshhaa
- Created: 2023-09-07T05:17:11.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2025-03-07T06:04:48.000Z (over 1 year ago)
- Last Synced: 2025-04-09T16:05:02.126Z (about 1 year ago)
- Topics: aws, aws-billing, aws-terraform, terraform, terraform-modules
- Language: HCL
- Homepage:
- Size: 20.5 KB
- Stars: 46
- Watchers: 3
- Forks: 45
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ AWS Billing Alert Terraform Module

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](https://aws.amazon.com/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](https://aws.amazon.com/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](https://aws.amazon.com/aws-cost-management/aws-bill/) 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:
```bash
cd /path/to/your/directory
```
3. Clone the repository:
```bash
git clone https://github.com/NotHarshhaa/aws-billing-alert-terraform.git
```
4. Move into the directory:
```bash
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:
```bash
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:
```bash
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:
```hcl
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:
```bash
terraform apply
```
---
## ๐ง Customization
### Billing Thresholds
Modify the `alert_thresholds` in your variables file to configure additional thresholds for your billing alerts:
```hcl
alert_thresholds = [100, 150, 200, 250]
```
### Email Subscription Auto-Confirmation
For testing purposes, you can enable automatic email confirmation by setting:
```hcl
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:
```hcl
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

> [!TIP]
> **Join Our [Telegram Community](https://t.me/prodevopsguy) || [Follow me on GitHub](https://github.com/NotHarshhaa) for more DevOps content!**