A Terraform module to create an AWS Cost Anomaly Monitor.
To use this module, you need to ensure the SNS topic you pass contains this statement in it's policy:
data "aws_iam_policy_document" "sns_topic_policy" {
policy_id = "sns_topic_policy"
statement {
sid = "AWSAnomalyDetectionSNSPublishingPermission"
actions = [
"SNS:Publish",
]
principals {
type = "Service"
identifiers = ["costalerts.amazonaws.com"]
}
resources = [
aws_sns_topic.example.arn,
]
}
}
For monintoring spend per provisioned AWS service
module "example" {
source = "github.com/synapsestudios/terraform-aws-cost-anomaly-monitor"
threshold = "10"
environment = "production"
sns_topic_arn = aws_sns_topic.example.arn
tags = {
"ProvisionedBy" = "terraform"
"Environment" = "production"
"Module" = "terraform-aws-cost-explorer-anomaly-monitor"
}
}
For monitoring total account spend.
module "example" {
source = "github.com/synapsestudios/terraform-aws-cost-anomaly-monitor"
threshold = "5"
environment = "production"
sns_topic_arn = aws_sns_topic.example.arn
type = "account"
account_list ["012345678901", "012345678901"]
tags = {
"ProvisionedBy" = "terraform"
"Environment" = "production"
"Module" = "terraform-aws-cost-explorer-anomaly-monitor"
}
}
No requirements.
Name | Version |
---|---|
aws | n/a |
No modules.
Name | Type |
---|---|
aws_ce_anomaly_monitor.account | resource |
aws_ce_anomaly_monitor.service | resource |
aws_ce_anomaly_subscription.this | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
account_list | List of AWS account numbers to monitor for cost anomalies. Required if using "type" argument | list(string) |
[] |
no |
environment | The environment this module is being deployed to | string |
"dev" |
no |
sns_topic_arn | The ARN of the SNS topic to send notifications to | string |
n/a | yes |
tags | Tags to apply to all resources created, see internal documentation for tagging standards | map(string) |
{ |
no |
threshold | Value between 0 and 100 representing the percentage of impact to trigger an alert | string |
"10" |
no |
type | The type of anomaly to detect for. Requires "account_list" argument. You won't be able to create a linked account monitor using this method from the linked account, the resource must be created in the parent account. | string |
"service" |
no |
Name | Description |
---|---|
cost_anomaly_subscription_arn | n/a |