-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam.tf
49 lines (42 loc) · 1009 Bytes
/
iam.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
resource "aws_iam_role" "sns_integration_role" {
name = "${var.api_name}__sns_integration_role"
assume_role_policy = jsonencode({
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Principal" : {
"Service" : "apigateway.amazonaws.com"
},
"Action" : "sts:AssumeRole"
}
]
})
tags = var.default_tags
depends_on = [module.pubsub]
lifecycle {
ignore_changes = [tags]
}
}
resource "aws_iam_policy" "sns_publish_policy" {
name = "${var.api_name}__sns_publish_policy"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = [
"sns:Publish"
]
Resource = [
local.topic_arn
]
}
]
})
depends_on = [module.pubsub]
}
resource "aws_iam_role_policy_attachment" "sns_integration_policy" {
policy_arn = aws_iam_policy.sns_publish_policy.arn
role = aws_iam_role.sns_integration_role.name
}