forked from moritzzimmer/terraform-aws-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiam_codebuild.tf
More file actions
87 lines (81 loc) · 2.37 KB
/
Copy pathiam_codebuild.tf
File metadata and controls
87 lines (81 loc) · 2.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
resource "aws_iam_role" "codebuild_role" {
count = var.codebuild_role_arn == "" ? 1 : 0
name = "${local.iam_role_prefix}-codebuild-${data.aws_region.current.name}"
tags = var.tags
assume_role_policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = "sts:AssumeRole"
Effect = "Allow"
Sid = ""
Principal = {
Service = "codebuild.amazonaws.com"
}
},
]
})
inline_policy {
name = "lambda-update-function-code-permissions"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"lambda:GetAlias",
"lambda:GetFunction",
"lambda:GetFunctionConfiguration",
"lambda:PublishVersion",
"lambda:UpdateFunctionCode"
]
Effect = "Allow"
Resource = "arn:${data.aws_partition.current.partition}:lambda:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:function:${var.function_name}"
},
{
Action = [
"logs:CreateLogStream",
"logs:CreateLogGroup",
"logs:PutLogEvents"
]
Effect = "Allow"
Resource = "arn:${data.aws_partition.current.partition}:logs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:log-group:/aws/codebuild/*"
},
{
Action = [
"s3:GetObject",
"s3:GetObjectVersion"
]
Effect = "Allow"
Resource = "${local.artifact_store_bucket_arn}/${local.pipeline_artifacts_folder}/source/*"
},
{
Action = [
"s3:PutObject",
]
Effect = "Allow"
Resource = "${local.artifact_store_bucket_arn}/${local.pipeline_artifacts_folder}/${local.deploy_output}/*"
}
]
})
}
dynamic "inline_policy" {
for_each = var.s3_bucket != "" ? [true] : []
content {
name = "lambda-s3-package-permissions"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"s3:GetObjectVersion"
]
Effect = "Allow"
Resource = [
"arn:${data.aws_partition.current.partition}:s3:::${var.s3_bucket}/${var.s3_key}"
]
}
]
})
}
}
}