This repository has been archived by the owner on Jun 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
iam.tf
83 lines (64 loc) · 1.32 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
resource "aws_iam_role" "lambda" {
name = local.naming_prefix
assume_role_policy = data.aws_iam_policy_document.lambda_role_trust.json
}
data "aws_iam_policy_document" "lambda_role_trust" {
statement {
sid = "LambdaTrust"
actions = [
"sts:AssumeRole"
]
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
}
}
resource "aws_iam_role_policy" "lambda_permissions" {
name = local.naming_prefix
role = aws_iam_role.lambda.id
policy = data.aws_iam_policy_document.lambda_permissions.json
}
data "aws_iam_policy_document" "lambda_permissions" {
statement {
sid = "Logging"
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
]
resources = [
"arn:aws:logs:*:*:*"
]
}
statement {
sid = "S3Access"
actions = [
"s3:Get*",
"s3:List*",
"s3:Describe*",
]
resources = [
"${var.cloudtrail_bucket.arn}/",
"${var.cloudtrail_bucket.arn}/*",
]
}
statement {
sid = "SSMAccess"
actions = [
"ssm:Get*",
]
resources = [
aws_ssm_parameter.slack_webhook.arn
]
}
statement {
sid = "SQSAccess"
actions = [
"sqs:*",
]
resources = [
aws_sqs_queue.bucket_notifications.arn
]
}
}