Skip to content

cloudandthings/terraform-aws-costnotifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Cost Notification Module

Purpose

This terraform module sends a daily cost report and the cost delta in a 7 day rolling period, scheduled on a CRON to a slack or teams channel of your choice.

The module also reports on the top 5 services attributing to the daily cost. Its a very rudimentary means of managing the cost of your AWS bill, but it does provide a 1000 ft view of the current expenses for the previous day. More on this module can be found on our blog on Medium.

Lambda deployment package

The Lambda function is deployed using a .zip deployment package. The package is contained within this module and also attached to the GitHub release.

You may choose one of the following options for the deployment:

  1. default: If no s3_* variables are specified, then the package is used by the lambda directly.
  2. recommended: s3_bucket can be specified to upload the package to the S3 bucket, for the lambda to use.
    • s3_prefix can be specified to override the default location.
    • upload_deployment_to_s3=false can be specified to disable the upload, in which case the package must be placed on s3 manually.

Examples

See examples dropdown on Terraform Cloud, or browse here.


Documentation


Inputs

Name Description Type Default Required
account_name Name of your account to Identify your account in the notification message string n/a yes
amber_threshold Percentage exceeded threshold to send an amber alert and notify the slack channel string "20" no
cloudwatch_logs_retention_in_days Specifies the number of days you want to retain log events in the specified log group. Possible values are: 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653. number 14 no
create_role Controls whether IAM role for Lambda Function should be created bool true no
emails_for_notifications List of emails to receive cost notifier notifications list(string) [] no
kms_key_arn The alias, alias ARN, key ID, or key ARN of an AWS KMS key used to encrypt all resources. string null no
lambda_description Lambda function description. string "This function sends AWS cost notifications. Source: github.com/cloudandthings/terraform-aws-costnotifier" no
lambda_role IAM role ARN attached to the Lambda Function. This governs both who / what can invoke your Lambda Function, as well as what resources our Lambda Function has access to. See Lambda Permission Model for more details. string "" no
lambda_runtime The lambda runtime to use. One of: ["python3.9", "python3.8", "python3.7"] string "python3.8" no
naming_prefix Naming prefix used to name all resources string n/a yes
notification_schedule CRON expression to schedule notification string "cron(0 20 ? * MON-SUN *)" no
permissions_boundary ARN of the policy that is used to set the permissions boundary for the role. string null no
red_threshold Percentage exceeded threshold to send a red alert and notify the slack channel string "50" no
s3_bucket S3 bucket for deployment package. string null no
s3_key S3 object key for deployment package. Otherwise, defaults to var.naming_prefix/local.deployment_filename. string null no
security_group_ids List of VPC security group IDs associated with the Lambda function. list(string) [] no
subnet_ids List of VPC subnet IDs associated with the Lambda function. list(string) [] no
tags A mapping of tags to assign to the resources. map(string) {} no
upload_deployment_to_s3 If true, the deployment package within this module repo will be copied to S3. If false then the S3 object must be uploaded separately. Ignored if s3_bucket is null. bool true no
webhook_type Either "slack" or "teams". string "slack" no
webhook_urls Webhook URLs to receive daily cost notifications on either Slack or Teams list(string) n/a yes

Modules

Name Source Version
billing_notifier_lambda terraform-aws-modules/lambda/aws 4.9.0

Outputs

Name Description
cost_notfier_lambda_name Created lambda's name

Providers

Name Version
aws ~> 4.9

Requirements

Name Version
terraform >= 0.15.0
aws ~> 4.9
null ~> 3.1

Resources

Name Type
aws_cloudwatch_event_rule.billing_notifier_lambda_event_rule resource
aws_cloudwatch_event_target.billing_notifier_lambda_event_target resource
aws_lambda_permission.billing_notifier_lambda_permission resource
aws_s3_object.deployment resource
aws_sns_topic.cost_notifier resource
aws_sns_topic_subscription.cost_notifier resource
aws_caller_identity.current data source