Skip to content

This module creates an AWS Cost Anomaly Detection monitor and subscription.

Notifications You must be signed in to change notification settings

StratusGrid/terraform-aws-anomaly-detection-alerts

Repository files navigation

Contact Us | Stratusphere FinOps | StratusGrid Home | Blog

terraform-aws-anomaly-detection-alerts

GitHub: StratusGrid/terraform-aws-anomaly-detection-alerts

This terraform module uses AWS Cloudformation under the hood to create AWS Cost Anomaly Detection monitors and subscriptions.

Repo Knowledge

This repo has several base requirements

  • The following packages are installed via brew: tflint, terrascan, terraform-docs, gitleaks, tfsec, pre-commit, tfsec
  • Install bash through Brew for Bash 5.0, otherwise it will fail with the error that looks like declare: -g: invalid option
  • If you need more tflint plugins, please edit the .tflint.hcl file with the instructions from here
  • It's highly recommend that you follow the Git Pre-Commit Instructions below, these will run in GitHub though they should be ran locally to reduce issues
  • By default Terraform docs will always run so our auto generated docs are always up to date
  • This repo has been tested with awsume

TFSec

See the pre-commit tfsec documentation here, this includes on how to bypass warnings

How to set this up in your Dev environment

Before this is applied, you need to configure the git hook on your local machine

#Verify you have bash5
brew install bash

# Test your pre-commit hooks - This will force them to run on all files
pre-commit run --all-files

# Add your pre-commit hooks forever
pre-commit install

Example

module "aws_anomaly_detection_alerts" {
 source     = "StratusGrid/anomaly-detection-alerts/aws"
 version    = "3.0.0"

 input_tags = merge(local.common_tags, {})

 cost_threshold     = 100                   # This is a sample of 100
 subscription_email = "[email protected]" # This is the email to send the billing alert to
}

Requirements

Name Version
terraform ~> 1.1
aws ~> 5.0

Resources

Name Type
aws_ce_anomaly_monitor.this resource
aws_ce_anomaly_subscription.this resource

Inputs

Name Description Type Default Required
cost_threshold Defines the amount in the account currency before AWS sends an email to the subscriber(s) that an anomaly was detected. number n/a yes
enable_cost_anomaly_detection Boolean to enable or disable Cost Explorer Anomaly Detection monitor and subscription. bool true no
input_tags Map of tags to apply to resources map(string)
{
"Developer": "StratusGrid",
"Provisioner": "Terraform"
}
no
subscription_email This is the email address that gets notified when an anomaly is detected. string n/a yes

Outputs

No outputs.


Note, manual changes to the README will be overwritten when the documentation is updated. To update the documentation, run terraform-docs -c .config/.terraform-docs.yml

About

This module creates an AWS Cost Anomaly Detection monitor and subscription.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages