Skip to content

Commit 162715e

Browse files
committed
Create one chatbot and topic per account
1 parent c62e49f commit 162715e

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
resource "aws_chatbot_slack_channel_configuration" "batch_processor_errors" {
2-
count = var.batch_error_notifications_enabled ? 1 : 0
3-
4-
configuration_name = "${local.resource_scope}-batch-processor-errors-slack-channel-config"
5-
iam_role_arn = aws_iam_role.batch_processor_errors_chatbot[0].arn
2+
configuration_name = "${var.environment}-batch-processor-errors-slack-channel-config"
3+
iam_role_arn = aws_iam_role.batch_processor_errors_chatbot.arn
64
slack_channel_id = var.environment == "prod" ? "C09EA0HE202" : "C09E48NDP18"
75
slack_team_id = "TJ00QR03U"
8-
sns_topic_arns = [aws_sns_topic.batch_processor_errors[0].arn]
6+
sns_topic_arns = [aws_sns_topic.batch_processor_errors.arn]
97
}
108

119
resource "aws_iam_role" "batch_processor_errors_chatbot" {
12-
count = var.batch_error_notifications_enabled ? 1 : 0
13-
14-
name = "${local.resource_scope}-batch-processor-errors-chatbot-channel-role"
10+
name = "${var.environment}-batch-processor-errors-chatbot-channel-role"
1511
assume_role_policy = jsonencode({
1612
Version = "2012-10-17"
1713
Statement = [
@@ -25,5 +21,6 @@ resource "aws_iam_role" "batch_processor_errors_chatbot" {
2521
},
2622
]
2723
})
24+
# To try: could test without this?
2825
managed_policy_arns = ["arn:aws:iam::aws:policy/AWSResourceExplorerReadOnlyAccess"]
2926
}

terraform/batch_processor_errors_sns_topic.tf

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
resource "aws_sns_topic" "batch_processor_errors" {
2-
count = var.batch_error_notifications_enabled ? 1 : 0
3-
name = "${local.resource_scope}-batch-processor-errors"
2+
name = "${var.environment}-batch-processor-errors"
43
}
54

65
resource "aws_sns_topic_policy" "batch_processor_errors_topic_policy" {
7-
count = var.batch_error_notifications_enabled ? 1 : 0
8-
arn = aws_sns_topic.batch_processor_errors[0].arn
6+
arn = aws_sns_topic.batch_processor_errors.arn
97
policy = jsonencode({
108
Version = "2012-10-17",
119
Statement = [
@@ -16,7 +14,7 @@ resource "aws_sns_topic_policy" "batch_processor_errors_topic_policy" {
1614
Service = "cloudwatch.amazonaws.com"
1715
},
1816
Action = "SNS:Publish",
19-
Resource = aws_sns_topic.batch_processor_errors[0].arn
17+
Resource = aws_sns_topic.batch_processor_errors.arn
2018
}
2119
]
2220
})

terraform/batch_processor_filter_lambda.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,6 @@ resource "aws_cloudwatch_metric_alarm" "batch_processor_filter_error_alarm" {
328328
statistic = "Sum"
329329
threshold = 1
330330
alarm_description = "This sets off an alarm for any error logs found in the batch processor filter Lambda function"
331-
alarm_actions = [aws_sns_topic.batch_processor_errors[0].arn]
331+
alarm_actions = [aws_sns_topic.batch_processor_errors.arn]
332332
treat_missing_data = "notBreaching"
333333
}

terraform/file_name_processor.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,6 @@ resource "aws_cloudwatch_metric_alarm" "file_name_processor_error_alarm" {
345345
statistic = "Sum"
346346
threshold = 1
347347
alarm_description = "This sets off an alarm for any error logs found in the file name processor Lambda function"
348-
alarm_actions = [aws_sns_topic.batch_processor_errors[0].arn]
348+
alarm_actions = [aws_sns_topic.batch_processor_errors.arn]
349349
treat_missing_data = "notBreaching"
350350
}

0 commit comments

Comments
 (0)