Skip to content

Commit 93b19a6

Browse files
committed
setting up account level config for slack and sns topic alerting
1 parent 6566cc3 commit 93b19a6

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
resource "aws_chatbot_slack_channel_configuration" "fhir_api_errors" {
2+
configuration_name = "${var.environment}-fhir-api-errors-slack-channel-config"
3+
iam_role_arn = aws_iam_role.fhir_api_errors_chatbot.arn
4+
slack_channel_id = var.environment == "prod" ? "C0A3LPKNKEE" : "C0A4F3G8J0G"
5+
slack_team_id = "TJ00QR03U"
6+
sns_topic_arns = [aws_sns_topic.fhir_api_errors.arn]
7+
}
8+
9+
resource "aws_iam_role" "fhir_api_errors_chatbot" {
10+
name = "${var.environment}-fhir-api-errors-chatbot-channel-role"
11+
assume_role_policy = jsonencode({
12+
Version = "2012-10-17"
13+
Statement = [
14+
{
15+
Action = "sts:AssumeRole"
16+
Effect = "Allow"
17+
Sid = "AssumeChatbotRole"
18+
Principal = {
19+
Service = "chatbot.amazonaws.com"
20+
}
21+
},
22+
]
23+
})
24+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
resource "aws_sns_topic" "fhir_api_errors" {
2+
name = "${var.environment}-fhir-api-errors"
3+
kms_master_key_id = aws_kms_key.fhir_api_errors_sns_encryption_key.arn
4+
}
5+
6+
resource "aws_sns_topic_policy" "fhir_api_errors_topic_policy" {
7+
arn = aws_sns_topic.fhir_api_errors.arn
8+
policy = jsonencode({
9+
Version = "2012-10-17",
10+
Statement = [
11+
{
12+
Sid = "AllowCloudWatchToPublish",
13+
Effect = "Allow",
14+
Principal = {
15+
Service = "cloudwatch.amazonaws.com"
16+
},
17+
Action = "SNS:Publish",
18+
Resource = aws_sns_topic.fhir_api_errors.arn
19+
}
20+
]
21+
})
22+
}

infrastructure/account/kms.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ resource "aws_kms_alias" "id_sync_sqs_encryption" {
179179
target_key_id = aws_kms_key.id_sync_sqs_encryption.key_id
180180
}
181181

182-
resource "aws_kms_key" "batch_processor_errors_sns_encryption_key" {
182+
resource "aws_kms_key" "error_alerts_sns_encryption_key" {
183183
description = "KMS key for encrypting the batch processor errors SNS Topic messages"
184184
deletion_window_in_days = 7
185185
enable_key_rotation = true
@@ -218,5 +218,10 @@ resource "aws_kms_key" "batch_processor_errors_sns_encryption_key" {
218218

219219
resource "aws_kms_alias" "batch_processor_errors_sns_encryption_key" {
220220
name = "alias/${var.environment}-batch-processor-errors-imms-sns-encryption"
221-
target_key_id = aws_kms_key.batch_processor_errors_sns_encryption_key.key_id
221+
target_key_id = aws_kms_key.error_alerts_sns_encryption_key.key_id
222+
}
223+
224+
resource "aws_kms_alias" "fhir_api_errors_sns_encryption_key" {
225+
name = "alias/${var.environment}-batch-processor-errors-imms-sns-encryption"
226+
target_key_id = aws_kms_key.error_alerts_sns_encryption_key.key_id
222227
}

0 commit comments

Comments
 (0)