-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsns.tf
60 lines (57 loc) · 1.43 KB
/
sns.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
resource "aws_sns_topic" "topic" {
name = var.topic_name
}
resource "aws_sns_topic_policy" "topic_policy" {
arn = aws_sns_topic.topic.arn
policy = <<EOF
{
"Version": "2008-10-17",
"Id": "__default_policy_ID",
"Statement": [
{
"Sid": "__default_statement_ID",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"SNS:GetTopicAttributes",
"SNS:SetTopicAttributes",
"SNS:AddPermission",
"SNS:RemovePermission",
"SNS:DeleteTopic",
"SNS:Subscribe",
"SNS:ListSubscriptionsByTopic",
"SNS:Publish",
"SNS:Receive"
],
"Resource": "${aws_sns_topic.topic.arn}",
"Condition": {
"StringEquals": {
"AWS:SourceOwner": "${var.account_id}"
}
}
},
{
"Sid": "AWSCodeStarNotifications_publish",
"Effect": "Allow",
"Principal": {
"Service": "codestar-notifications.amazonaws.com"
},
"Action": "SNS:Publish",
"Resource": "${aws_sns_topic.topic.arn}",
"Condition": {
"StringEquals": {
"aws:SourceAccount": "${var.account_id}"
}
}
}
]
}
EOF
}
resource "aws_sns_topic_subscription" "user_updates_sqs_target" {
topic_arn = aws_sns_topic.topic.arn
protocol = "lambda"
endpoint = aws_lambda_function.main.arn
}