Skip to content

Terraform module to deploy an AWS budget forecast, automatically sending notifications when usage exceeds specified budget limits, ensuring proactive cost management and alerts.

License

Notifications You must be signed in to change notification settings

squareops/terraform-aws-billing-notifications

Repository files navigation

terraform-aws-billing

AWS Budget Forecast Notification

Configuration in this directory creates set of AWS resources which may be sufficient for a fully working stage or prod Terraform module - creates an AWS Budget with notification via SNS enabled/Email enabled with optional sns topic creation (or use a pre-existing one) to alert when a U$S (currency actually configurable) budget forecasted threshold % is reached (currently 100% of the limit_amount).

Provides an AWS budget resource (aws_budgets_budget). Budgets use the cost visualisation provided by Cost Explorer to show you the status of your budgets, to provide forecasts of your estimated costs, and to track your AWS usage, including your free tier usage.

Please check the input parameters for a better understanding of it.

Usage Example

module "aws_budget_alert" {
  source            = "git@github.com:sq-ia/terraform-aws-billing.git"
  name              = "daily-alert"
  environment       = "prod"
  account_id        = "222222222222"
  budget_type       = "COST"
  limit_amount      = "10"
  limit_unit        = "USD"
  time_period_start = "2023-11-16_00:00"
  time_unit         = "DAILY"
  notification = {
    comparison_operator = "GREATER_THAN"
    threshold           = 100
    threshold_type      = "PERCENTAGE"
    notification_type   = "ACTUAL"
  }
  cost_types = {
    include_credit             = true
    include_discount           = true
    include_other_subscription = true
    include_recurring          = true
    include_refund             = true
    include_subscription       = true
    include_support            = true
    include_tax                = true
    include_upfront            = true
    use_blended                = true
  }
  slack_notification_enabled = true
  slack_channel_id           = "XXXXXZZZZ"
  slack_workspace_id         = "ABCDUTSSZ"
  email_notification_enabled = true
  email_address              = "notification.com"
}

Usage

To run this example you need to execute:

$ terraform init
$ terraform plan
$ terraform apply

Or if using the Makefile in this repo you need to execute:

$ make init
$ make plan
$ make apply

Note that this example may create resources which can cost money (AWS EC2, for example). Run terraform destroy or make destroy when you don't need these resources.

Requirements

No requirements.

Providers

Name Version
aws n/a
awscc n/a

Modules

No modules.

Resources

Name Type
aws_budgets_budget.aws_budget_report resource
aws_iam_policy.chatbot_role_policy resource
aws_iam_role.chatbot_role resource
aws_iam_role_policy_attachment.chatbot_policy_attach resource
aws_sns_topic.aws_budget_alerts resource
aws_sns_topic_policy.sns_topic_policy resource
aws_sns_topic_subscription.aws_budget_alerts_target resource
awscc_chatbot_slack_channel_configuration.aws_budget_alerts_slack resource
aws_iam_policy_document.aws_budgets_assume_role_policy data source
aws_iam_policy_document.chatbot_policy data source
aws_iam_policy_document.sns_topic_policy data source

Inputs

Name Description Type Default Required
slack_notification_enabled Flag to enable or disable Slack notifications. bool false no
slack_channel_id The ID of the Slack channel for notifications. string "" no
slack_workspace_id The ID of the Slack workspace for notifications. string "" no
notification Configuration for budget notifications.
object({
comparison_operator = optional(string, "GREATER_THAN") # LESS_THAN, EQUAL_TO or GREATER_THAN
threshold = number
threshold_type = string # PERCENTAGE or ABSOLUTE_VALUE
notification_type = optional(string, "ACTUAL") # ACTUAL or FORECASTED
})
n/a yes
cost_types Configuration for included cost types in the budget. any
{
"include_credit": false,
"include_discount": true,
"include_other_subscription": true,
"include_recurring": true,
"include_refund": false,
"include_subscription": true,
"include_support": true,
"include_tax": true,
"include_upfront": true,
"use_blended": false
}
no
time_period_start The start date of the budget time period(e.g., 2017-01-01_12:00). string "" no
time_period_end The start date of the budget time period(e.g., 2017-01-01_12:00). string "" no
time_unit The unit of time for the budget (e.g., MONTHLY, QUARTERLY, ANNUALLY and DAILY). string "" no
name A unique name for the budget configuration. string "" no
environment The environment for which the budget is configured. string "" no
account_id The AWS account ID for which the budget is created. string "" no
budget_type The type of budget (e.g., COST, USAGE) for monitoring. string "" no
limit_amount The budgeted amount for the specified time period. number n/a yes
limit_unit The unit of measurement for the budgeted amount(e.g,, USD, GB). string "" no
email_notification_enabled Flag to enable or disable Slack notifications. bool false no
email_address n/a string "" no

Outputs

Name Description
sns_topic_arn The Amazon Resource Name (ARN) of the created AWS SNS topic for budget alerts.
budget_report_id The ID of the AWS Budgets budget report created for monitoring costs.
chatbot_role_arn The ARN of the AWS IAM role created for the chatbot to assume.

Contribution & Issue Reporting

To report an issue with a project:

  1. Check the repository's issue tracker on GitHub
  2. Search to see if the issue has already been reported
  3. If you can't find an answer to your question in the documentation or issue tracker, you can ask a question by creating a new issue. Be sure to provide enough context and details so others can understand your problem.

License

Apache License, Version 2.0, January 2004 (http://www.apache.org/licenses/).

Support Us

To support a GitHub project by liking it, you can follow these steps:

  1. Visit the repository: Navigate to the GitHub repository.

  2. Click the "Star" button: On the repository page, you'll see a "Star" button in the upper right corner. Clicking on it will star the repository, indicating your support for the project.

  3. Optionally, you can also leave a comment on the repository or open an issue to give feedback or suggest changes.

Starring a repository on GitHub is a simple way to show your support and appreciation for the project. It also helps to increase the visibility of the project and make it more discoverable to others.

Who we are

We believe that the key to success in the digital age is the ability to deliver value quickly and reliably. That’s why we offer a comprehensive range of DevOps & Cloud services designed to help your organization optimize its systems & Processes for speed and agility.

  1. We are an AWS Advanced consulting partner which reflects our deep expertise in AWS Cloud and helping 100+ clients over the last 4 years.
  2. Expertise in Kubernetes and overall container solution helps companies expedite their journey by 10X.
  3. Infrastructure Automation is a key component to the success of our Clients and our Expertise helps deliver the same in the shortest time.
  4. DevSecOps as a service to implement security within the overall DevOps process and helping companies deploy securely and at speed.
  5. Platform engineering which supports scalable,Cost efficient infrastructure that supports rapid development, testing, and deployment.
  6. 24*7 SRE service to help you Monitor the state of your infrastructure and eradicate any issue within the SLA.

We provide support on all of our projects, no matter how small or large they may be.

To find more information about our company, visit squareops.com, follow us on Linkedin, or fill out a job application. If you have any questions or would like assistance with your cloud strategy and implementation, please don't hesitate to contact us.

About

Terraform module to deploy an AWS budget forecast, automatically sending notifications when usage exceeds specified budget limits, ensuring proactive cost management and alerts.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages