-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-role.tf
96 lines (92 loc) · 2.04 KB
/
example-role.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
84
85
86
87
88
89
90
91
92
93
94
95
96
// There are two roles in this example:
//
// 1. The role that lambdafy tool requires to be able to create and manage the
// functions (lambdafy).
resource "aws_iam_user" "lambdafy" {
name = "lambdafy-cli"
}
resource "aws_iam_user_policy" "lambdafy" {
name = aws_iam_user.lambdafy.name
user = aws_iam_user.lambdafy.name
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["lambda:*"],
"Resource": ["*"]
},
{
"Effect": "Allow",
"Action": [
"iam:GetRole",
"iam:GetRolePolicy",
"iam:ListAttachedRolePolicies",
"iam:ListRolePolicies",
"iam:PassRole",
"iam:SimulatePrincipalPolicy"
],
"Resource": ["*"]
},
{
"Effect": "Allow",
"Action": [
"scheduler:DeleteScheduleGroup",
"scheduler:CreateScheduleGroup",
"scheduler:CreateSchedule",
"scheduler:DeleteSchedule"
],
"Resource": ["*"]
},
{
"Effect": "Allow",
"Action": [
"iam:CreateRole",
"iam:PutRolePolicy",
"iam:UpdateRole"
],
"Resource": [
"arn:aws:iam::*:role/lambdafy-*"
]
},
{
"Effect": "Allow",
"Action": [
"ecr:*"
],
"Resource": ["*"]
},
{
"Effect": "Allow",
"Action": [
"ec2:DescribeSecurityGroups",
"ec2:DescribeSubnets",
"ec2:DescribeVpcs"
],
"Resource": ["*"]
}
]
}
EOF
}
// 2. The role for the Lambda function itself (fn) - this is not needed if
// 'role: generate' is used in the lambdafy spec.
resource "aws_iam_role" "fn" {
name = "my-custom-function"
assume_role_policy = <<EOF
{{.AssumeRolePolicy -}}
EOF
inline_policy {
name = "main"
// TODO add your custom statements after the main one below. E.g.:
// {
// "Effect": "Allow",
// "Action": ["ssm:GetParameter"],
// "Resource": ["arn:aws:ssm:*:*:parameter/my_fn/*"]
// }
policy = <<EOF
{{.InlinePolicy -}}
EOF
}
}