-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda-iam.tf
More file actions
65 lines (52 loc) · 1.37 KB
/
lambda-iam.tf
File metadata and controls
65 lines (52 loc) · 1.37 KB
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
resource "aws_iam_role_policy" "lambda_policy" {
name = "lambda_policy"
role = aws_iam_role.lambda_role.id
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Sid = "Stmt1643314639908"
Action = "logs:*"
Effect = "Allow"
Resource = "*"
},
{
Sid = "Stmt1643497337398"
Action = [
"lambda:InvokeAsync",
"lambda:InvokeFunction"
],
Effect = "Allow"
Resource = aws_lambda_function.cat.arn
}
]
})
}
resource "aws_iam_role_policy" "cat_lambda_policy" {
name = "cat_lambda_policy"
role = aws_iam_role.cat_lambda_role.id
policy = file("iam/cat-lambda-policy.json")
}
resource "aws_iam_role" "cat_lambda_role" {
name = "cat_lambda_role"
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Principal = {
Service = "lambda.amazonaws.com"
}
Action = "sts:AssumeRole"
}
]
})
}
resource "aws_iam_role" "lambda_role" {
name = "lambda_role"
assume_role_policy = file("iam/lambda-assume-role.json")
}
resource "aws_iam_role_policy_attachment" "iam_role_policy_attachment_lambda_execution_access" {
role = aws_iam_role.lambda_role.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}