You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.2 KiB
HCL
55 lines
1.2 KiB
HCL
resource "aws_sns_topic" "this" {
|
|
name = var.namespace
|
|
}
|
|
|
|
resource "aws_sns_topic_subscription" "this" {
|
|
topic_arn = aws_sns_topic.this.arn
|
|
protocol = "lambda"
|
|
endpoint = aws_lambda_function.lambda.arn
|
|
raw_message_delivery = false
|
|
}
|
|
|
|
resource "aws_sns_topic_policy" "this" {
|
|
arn = aws_sns_topic.this.arn
|
|
policy = <<EOF
|
|
{
|
|
"Version": "2008-10-17",
|
|
"Statement": [
|
|
{
|
|
"Sid": "AllowAccountNotifications",
|
|
"Effect": "Allow",
|
|
"Principal": {
|
|
"AWS": "*"
|
|
},
|
|
"Action": [
|
|
"SNS:Publish",
|
|
"SNS:RemovePermission",
|
|
"SNS:SetTopicAttributes",
|
|
"SNS:DeleteTopic",
|
|
"SNS:ListSubscriptionsByTopic",
|
|
"SNS:GetTopicAttributes",
|
|
"SNS:Receive",
|
|
"SNS:AddPermission",
|
|
"SNS:Subscribe"
|
|
],
|
|
"Resource": "${aws_sns_topic.this.arn}",
|
|
"Condition": {
|
|
"StringEquals": {
|
|
"AWS:SourceOwner": "${local.account_id}"
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"Sid": "AllowBackupNotifications",
|
|
"Effect": "Allow",
|
|
"Principal": {
|
|
"Service": "backup.amazonaws.com"
|
|
},
|
|
"Action": "SNS:Publish",
|
|
"Resource": "${aws_sns_topic.this.arn}"
|
|
}
|
|
]
|
|
}
|
|
EOF
|
|
}
|