forked from FormidableLabs/terraform-aws-serverless
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolicy-developer.tf
More file actions
147 lines (130 loc) · 3.35 KB
/
policy-developer.tf
File metadata and controls
147 lines (130 loc) · 3.35 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
###############################################################################
# Policy: Developer
# -----------------
# A developer role can:
# - Update the serverless application/stack
# - View logs and run various `serverless` commands
###############################################################################
resource "aws_iam_policy" "developer" {
name = local.tf_group_developer_name
path = "/"
policy = data.aws_iam_policy_document.developer.json
}
data "aws_iam_policy_document" "developer" {
# CloudFormation (`sls deploy`)
statement {
actions = [
"cloudformation:ValidateTemplate",
]
# Only allows wildcard.
# https://iam.cloudonaut.io/reference/cloudformation/ValidateTemplate.html
resources = [
"*",
]
}
statement {
actions = [
"cloudformation:DescribeStackEvents",
"cloudformation:DescribeStackResource",
"cloudformation:DescribeStackResources",
"cloudformation:ListChangeSets",
"cloudformation:ListStackResources",
"cloudformation:Get*",
"cloudformation:UpdateStack",
"cloudformation:DescribeStacks",
]
resources = [
local.sls_cloudformation_arn,
]
}
# S3 (`sls deploy`)
statement {
actions = [
"s3:ListBucketVersions",
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket",
"s3:DeleteObject",
]
resources = [
local.sls_deploy_bucket_arn,
]
}
# IAM (`sls deploy`)
statement {
actions = [
"iam:PassRole", # Assign to Lambdas
"iam:GetRole",
]
resources = [
local.lambda_role_iam_arn,
]
}
# Lambda (`sls deploy`)
statement {
# Note:
# - `UpdateEventSourceMapping`: We don't include, but not it has a very
# differently structured ARN if we later add it. See, e.g.
# https://iam.cloudonaut.io/reference/lambda/UpdateEventSourceMapping.html
actions = [
"lambda:GetAlias",
"lambda:GetFunction",
"lambda:GetFunctionConfiguration",
"lambda:GetPolicy",
"lambda:ListAliases",
"lambda:ListVersionsByFunction",
"lambda:AddPermission",
"lambda:CreateAlias",
"lambda:InvokeFunction",
"lambda:PublishVersion",
"lambda:RemovePermission",
"lambda:Update*",
]
resources = [
local.sls_lambda_arn,
]
}
# Lambda Layers (`sls deploy`)
statement {
# Note:
# - `DeleteLayerVersion` is needed because the old layer is deleted on update.
actions = [
"lambda:GetLayerVersion",
"lambda:PublishLayerVersion",
"lambda:DeleteLayerVersion",
]
resources = [
local.sls_layer_arn,
]
}
# API Gateway (`sls deploy`)
statement {
actions = [
"apigateway:GET",
"apigateway:PATCH",
"apigateway:POST",
"apigateway:PUT",
"apigateway:DELETE",
"apigateway:UpdateRestApiPolicy",
]
resources = [
local.sls_apigw_arn,
local.sls_apigw_tags_arn,
]
}
# Logs (`sls logs`)
statement {
actions = [
"logs:DescribeLogStreams",
"logs:DescribeLogGroups",
"logs:FilterLogEvents",
"logs:GetLogEvents",
]
# Note: Need trailing `*` in `log-stream:*` to allow viewing specific logs in AWS console.
# https://iam.cloudonaut.io/reference/logs.html
resources = [
local.sls_log_stream_arn,
"${local.sls_log_stream_arn}*",
]
}
}