-
Notifications
You must be signed in to change notification settings - Fork 18
/
iam.tf
64 lines (57 loc) · 1.43 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
resource "aws_iam_role" "example_lambda" {
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
EOF
}
resource "aws_iam_role_policy_attachment" "example_lambda" {
policy_arn = "${aws_iam_policy.example_lambda.arn}"
role = "${aws_iam_role.example_lambda.name}"
}
resource "aws_iam_policy" "example_lambda" {
policy = "${data.aws_iam_policy_document.example_lambda.json}"
}
data "aws_iam_policy_document" "example_lambda" {
statement {
sid = "AllowSQSPermissions"
effect = "Allow"
resources = ["arn:aws:sqs:*"]
actions = [
"sqs:ChangeMessageVisibility",
"sqs:DeleteMessage",
"sqs:GetQueueAttributes",
"sqs:ReceiveMessage",
]
}
statement {
sid = "AllowInvokingLambdas"
effect = "Allow"
resources = ["arn:aws:lambda:ap-southeast-1:*:function:*"]
actions = ["lambda:InvokeFunction"]
}
statement {
sid = "AllowCreatingLogGroups"
effect = "Allow"
resources = ["arn:aws:logs:ap-southeast-1:*:*"]
actions = ["logs:CreateLogGroup"]
}
statement {
sid = "AllowWritingLogs"
effect = "Allow"
resources = ["arn:aws:logs:ap-southeast-1:*:log-group:/aws/lambda/*:*"]
actions = [
"logs:CreateLogStream",
"logs:PutLogEvents",
]
}
}