Skip to content

This module will deploy a lambda function which will listen for ec2 instance running/stopped/terminated events and put/delete CreditBalance alarms for cpu credits.

License

Notifications You must be signed in to change notification settings

StratusGrid/terraform-aws-lambda-event-handler-cpu-creditbalance

Repository files navigation

Contact Us | Stratusphere FinOps | StratusGrid Home | Blog

terraform-aws-lambda-event-handler-cpu-creditbalance

GitHub: StratusGrid/terraform-aws-lambda-event-handler-cpu-creditbalance

This module will deploy a lambda function which will listen for ec2 instance running/stopped/terminated events and put/delete CreditBalance alarms for cpu credits.

Example:

module "cpu_credit_balance_lambda" {
  source   = "StratusGrid/lambda-event-handler-cpu-creditbalance/aws"
  version  = "2.1.0"
  # source   = "github.com/StratusGrid/terraform-aws-lambda-event-handler-cpu-creditbalance"

  name_prefix      = var.name_prefix
  name_suffix      = local.name_suffix
  unique_name      = "event-handler-cpu-credit-balance"
  sns_alarm_target = aws_sns_topic.infrastructure_alerts.arn
  input_tags       = merge(local.common_tags, {})
}

Resources

Name Type
aws_cloudwatch_event_rule.event resource
aws_cloudwatch_event_target.function_target resource
aws_cloudwatch_log_group.log_group resource
aws_iam_role.function_role resource
aws_iam_role_policy.function_policy resource
aws_iam_role_policy.function_policy_default resource
aws_kms_key.log_key resource
aws_lambda_function.function resource
aws_lambda_permission.allow_cloudwatch_event_trigger resource

Inputs

Name Description Type Default Required
alarm_period Number of seconds for period value of alarm (Less than 300 will result in 'insufficient data' unless you have detailed monitoring enabled!) string "300" no
alarm_threshold_standard Float value for alarm threshold to be used as lower limit for CPU Credit Balance on Standard Burst instances(e.g. 25.0) string "25.0" no
alarm_threshold_unlimited Float value for alarm threshold to be used as upper limit for CPU Surplus Credit Balance on Unlimited Burst instances (e.g. 1.0) string "1.0" no
cloudwatch_log_retention_days Number of days for retention period of Lambda logs string "30" no
input_tags Map of tags to apply to resources map(string)
{
"Developer": "StratusGrid",
"Provisioner": "Terraform"
}
no
kms_log_key_deletion_window Duration (in day) of kms key created, default is 30 number n/a yes
lambda_tracing_option Lambda Tracing option whether to sample and trace a subset of incoming requests with AWS X-Ray. string "Active" no
name_prefix String to prefix on object names string "" no
name_suffix String to append to object names. This is optional, so start with dash if using string "" no
region Specifies the region where the logs are stored string "us-east-1" no
sns_alarm_target ARN for sns alarm to be targeted for performance alerts string "" no
unique_name Unique string to describe resources. E.g. 'ebs-append' would make (type) 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 will deploy a lambda function which will listen for ec2 instance running/stopped/terminated events and put/delete CreditBalance alarms for cpu credits.

Resources

License

Stars

Watchers

Forks

Packages

No packages published