forked from aws-samples/sagemaker-mlops-reusable-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sns.tf
50 lines (41 loc) · 1.22 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
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: MIT-0
resource "aws_sns_topic" "pipeline_success_topic"{
name = join("-", compact([var.prefix, var.environment, "pl-success-topic2"]))
}
resource "aws_sns_topic" "pipeline_error_topic"{
name = join("-", compact([var.prefix, var.environment, "pl-error-topic2"]))
}
resource "aws_sns_topic_policy" "pipeline_success_topic_policy" {
arn = aws_sns_topic.pipeline_success_topic.arn
policy = data.aws_iam_policy_document.preprod_sns_topic_policy.json
}
data "aws_iam_policy_document" "preprod_sns_topic_policy" {
statement {
actions = [
"SNS:Subscribe",
"SNS:SetTopicAttributes",
"SNS:RemovePermission",
"SNS:Receive",
"SNS:Publish",
"SNS:ListSubscriptionsByTopic",
"SNS:GetTopicAttributes",
"SNS:DeleteTopic",
"SNS:AddPermission",
]
effect = "Allow"
principals {
type = "AWS"
identifiers = ["*"]
}
condition {
test = "StringEquals"
variable = "AWS:SourceOwner"
values = [
var.account_id
]
}
resources = [
aws_sns_topic.pipeline_success_topic.arn,
]
}
}