Skip to content

Commit 15e1880

Browse files
committed
[NRL-1158] Switch sns config for backups to match AWS examples
1 parent 27b9404 commit 15e1880

File tree

1 file changed

+14
-2
lines changed
  • terraform/account-wide-infrastructure/modules/backup-source

1 file changed

+14
-2
lines changed

terraform/account-wide-infrastructure/modules/backup-source/sns.tf

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
resource "aws_sns_topic" "backup" {
22
name = "${local.resource_name_prefix}-notifications"
33
kms_master_key_id = var.bootstrap_kms_key_arn
4-
policy = data.aws_iam_policy_document.allow_backup_to_sns.json
54
}
65

76
data "aws_iam_policy_document" "allow_backup_to_sns" {
@@ -19,12 +18,25 @@ data "aws_iam_policy_document" "allow_backup_to_sns" {
1918
identifiers = ["backup.amazonaws.com"]
2019
}
2120

22-
resources = ["*"]
21+
resources = [
22+
aws_sns_topic.backup.arn
23+
]
2324

2425
sid = "allow_backup"
26+
27+
condition {
28+
test = "StringEquals"
29+
variable = "aws:SourceAccount"
30+
values = ["${data.aws_caller_identity.current.account_id}"]
31+
}
2532
}
2633
}
2734

35+
resource "aws_sns_topic_policy" "backup_sns_policy" {
36+
arn = aws_sns_topic.backup.arn
37+
policy = data.aws_iam_policy_document.allow_backup_to_sns.json
38+
}
39+
2840
resource "aws_sns_topic_subscription" "aws_backup_notifications_email_target" {
2941
count = length(var.notification_target_email_addresses)
3042
topic_arn = aws_sns_topic.backup.arn

0 commit comments

Comments
 (0)