This Terraform module streamlines AWS cost management by automatically setting up AWS Cost Anomaly Detection. It continuously monitors your cloud expenses and instantly alerts you to unexpected cost spikes—helping you optimize your AWS billing, prevent overspending, and maintain tight control over your cloud budget. Whether you're looking to enhance cost monitoring, streamline AWS cost management, or integrate automated cost alerts into your infrastructure, this module is your key to a more predictable and efficient AWS spending strategy.
- Simple Deployment: Intuitive and declarative Terraform module for cost anomaly detection.
- Automated Configuration: Automatically configures AWS Cost Explorer and anomaly detection settings.
- Real-time Alerts: Receive instant notifications for cost anomalies.
- Cost Optimization: Gain insights to optimize AWS spending and identify cost-saving opportunities.
- Scalability: Supports large-scale AWS environments with ease.
terraform {
# Setup yor state backend here.
# Either s3 / local
}
module "cost_anomaly_detection" {
source = "github.com/omers/aws-cost-anomaly-detector.git"
region = "us-west-2"
environment = "production"
emails = ["devops@example.com", "finance@example.com"]
raise_amount_percent = "20"
raise_amount_absolute = "100"
# Optional PagerDuty integration
create_pagerduty = true
pagerduty_endpoint = "https://events.pagerduty.com/integration/abcdef123456/enqueue"
resource_tags = {
ManagedBy = "Terraform"
Project = "CostOptimization"
}
}
- Terraform v1.0+
- AWS account with appropriate permissions
- AWS provider v5.6.2 or later
- Create a new PagerDuty service with the Amazon CloudWatch integration type.
- Copy the PagerDuty Integration URL to the
pagerduty_endpoint
input variable. - Set
create_pagerduty = true
in your module configuration.
Name | Version |
---|---|
aws | ~> 5.0 |
Name | Version |
---|---|
aws | ~> 5.0 |
No modules.
Name | Type |
---|---|
aws_ce_anomaly_monitor.anomaly_monitor | resource |
aws_ce_anomaly_subscription.realtime_subscription | resource |
aws_sns_topic.cost_anomaly_updates | resource |
aws_sns_topic_policy.default | resource |
aws_sns_topic_subscription.pagerduty | resource |
aws_sns_topic_subscription.topic_email_subscription | resource |
aws_caller_identity.current | data source |
aws_iam_policy_document.sns_topic_policy | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
create_pagerduty | Set to true in order to send notifications to PagerDuty | bool |
false |
no |
emails | List of email addresses to notify | list(any) |
n/a | yes |
environment | The account environment (Prod / Dev etc.) | string |
n/a | yes |
pagerduty_endpoint | The PagerDuty HTTPS endpoint where SNS notifications will be sent to | string |
n/a | yes |
raise_amount_absolute | The Absolut increase in USD to trigger the detector. (ANOMALY_TOTAL_IMPACT_ABSOLUTE) | string |
n/a | yes |
raise_amount_percent | An Expression object used to specify the anomalies that you want to generate alerts for. The precentage service cost increase than the expected | string |
n/a | yes |
region | AWS Region | string |
n/a | yes |
resource_tags | Tags to set for all resources | map(string) |
{} |
no |
Name | Description |
---|---|
sns_arn | n/a |