-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIAMshit.tf
42 lines (39 loc) · 991 Bytes
/
IAMshit.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
resource "aws_iam_role" "lambda-role" {
name = "lambda-role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow"
}
]
}
EOF
}
data "aws_iam_policy_document" "lambda-iam-policy-doc" {
statement {
actions = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"lambda:InvokeFunction",
"execute-api:ManageConnections"
]
effect = "Allow"
resources = ["*"]
sid = "CreateCloudWatchLogs"
}
}
resource "aws_iam_policy" "lambda-logs-policy" {
name = "iam-lambda-policy"
policy = data.aws_iam_policy_document.lambda-iam-policy-doc.json
}
resource "aws_iam_role_policy_attachment" "lambda_logs" {
role = aws_iam_role.lambda-role.name
policy_arn = aws_iam_policy.lambda-logs-policy.arn
}