This module provides the the infrastructure to send Budget and Cloudwatch alarms to msteams.
provider "aws" {
region = "eu-west-2"
}
resource "random_pet" "this" {
length = 2
}
module "alarm_module" {
source = "../../"
prefix = random_pet.this.id
msteams_webhook_budget_alarm = var.MS_TEAMS_WEB_HOOK
msteams_webhook_cloudwatch_alarm = var.MS_TEAMS_WEB_HOOK
cloudwatch_retention_in_days = 7
overwrite_msteams_webhook_budget_alarm = true
overwrite_msteams_webhook_cloudwatch_alarm = true
}
resource "aws_budgets_budget" "budget" {
name = "${random_pet.this.id}-monthly-budget"
budget_type = "COST"
limit_amount = "50"
limit_unit = "USD"
time_unit = "MONTHLY"
notification {
comparison_operator = "GREATER_THAN"
threshold = 100
threshold_type = "PERCENTAGE"
notification_type = "FORECASTED"
subscriber_sns_topic_arns = [
module.alarm_module.budget_alarm_topic_arn
]
}
}
resource "aws_cloudwatch_metric_alarm" "concurrent_lambdas" {
alarm_name = "${random_pet.this.id}-concurrent-lambdas-alarm"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
metric_name = "ConcurrentExecutions"
namespace = "AWS/Lambda"
period = "300"
statistic = "Sum"
threshold = 10
alarm_actions = [
module.alarm_module.cloudwatch_alarm_topic_arn
]
alarm_description = "https://nhsd-confluence.digital.nhs.uk/display/SPACE/PlaybookA"
treat_missing_data = "notBreaching"
}
This example may create resources which cost money. Run terraform destroy
when you don't need the resources.
Name | Description | Type | Default | Required |
---|---|---|---|---|
cloudwatch_retention_in_days | The number of days cloudwatch logs should be kept | number |
365 |
no |
lambda_reserved_concurrency | Reserved concurrency is the maximum number of concurrent instances you want to allocate to your function. When a function has reserved concurrency, no other function can use that concurrency | number |
1 |
no |
lambda_timeout | The time in seconds the lambda function is allowed to run before it times out | number |
"60" |
no |
msteams_webhook_budget_alarm | The microsoft teams webhook | string |
n/a | yes |
msteams_webhook_budget_ssm_lifecycle_ignore_changes_value | True to set the lifecycle {ignore = [value]}, e.i. the ssm parameter will not be overwritten on deploy | bool |
n/a | yes |
msteams_webhook_cloudwatch_alarm | The microsoft teams webhook | string |
n/a | yes |
msteams_webhook_cloudwatch_ssm_lifecycle_ignore_changes_value | True to set the lifecycle {ignore = [value]}, e.i. the ssm parameter will not be overwritten on deploy | bool |
n/a | yes |
prefix | The name you want the resources to be prefixed with, for example dev, test, prod | string |
n/a | yes |
No modules.
Name | Description |
---|---|
budget_alarm_topic_arn | The budget alarm topic arn. Subscribe your budget alarms to this topic |
cloudwatch_alarm_topic_arn | The cloudwatch alarm topic arn. Subscribe your cloudwatch alarms to this topic |
msteams_lambda_function_name | n/a |
Name | Version |
---|---|
archive | >= 2.0.0 |
aws | >= 4.0.0 |
null | >= 3.2 |
Name | Version |
---|---|
terraform | >= 1.3.9 |
archive | >= 2.0.0 |
aws | >= 4.0.0 |
null | >= 3.2 |