Skip to content

Commit 6fffbf9

Browse files
authored
added optional sns topic in alarm actions (#31)
1 parent ad7f537 commit 6fffbf9

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ In order to run all checks at any point run the following command:
5959

6060
| Name | Version |
6161
|------|---------|
62-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.24.0 |
62+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.44.0 |
6363

6464
## Modules
6565

@@ -90,6 +90,7 @@ No modules.
9090
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | Name prefix for resources on AWS | `any` | n/a | yes |
9191
| <a name="input_scale_target_max_capacity"></a> [scale\_target\_max\_capacity](#input\_scale\_target\_max\_capacity) | The max capacity of the scalable target | `number` | `5` | no |
9292
| <a name="input_scale_target_min_capacity"></a> [scale\_target\_min\_capacity](#input\_scale\_target\_min\_capacity) | The min capacity of the scalable target | `number` | `1` | no |
93+
| <a name="input_sns_topic_arn"></a> [sns\_topic\_arn](#input\_sns\_topic\_arn) | The ARN of an SNS topic to send notifications on alarm actions. | `string` | `""` | no |
9394
| <a name="input_tags"></a> [tags](#input\_tags) | Resource tags | `map(string)` | `{}` | no |
9495

9596
## Outputs

main.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ resource "aws_cloudwatch_metric_alarm" "cpu_high" {
1414
ClusterName = var.ecs_cluster_name
1515
ServiceName = var.ecs_service_name
1616
}
17-
alarm_actions = [aws_appautoscaling_policy.scale_up_policy.arn]
18-
17+
alarm_actions = [
18+
aws_appautoscaling_policy.scale_up_policy.arn,
19+
var.sns_topic_arn != "" ? var.sns_topic_arn : null
20+
]
1921
tags = var.tags
2022
}
2123

@@ -35,8 +37,10 @@ resource "aws_cloudwatch_metric_alarm" "cpu_low" {
3537
ClusterName = var.ecs_cluster_name
3638
ServiceName = var.ecs_service_name
3739
}
38-
alarm_actions = [aws_appautoscaling_policy.scale_down_policy.arn]
39-
40+
alarm_actions = [
41+
aws_appautoscaling_policy.scale_down_policy.arn,
42+
var.sns_topic_arn != "" ? var.sns_topic_arn : null
43+
]
4044
tags = var.tags
4145
}
4246

variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,10 @@ variable "scale_target_min_capacity" {
6666
default = 1
6767
type = number
6868
}
69+
70+
variable "sns_topic_arn" {
71+
# Optional ARN of an SNS topic for sending notifications
72+
type = string
73+
description = "The ARN of an SNS topic to send notifications on alarm actions."
74+
default = "" # Set an empty string as default to avoid potential errors
75+
}

0 commit comments

Comments
 (0)