forked from moritzzimmer/terraform-aws-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiam_codedeploy.tf
More file actions
75 lines (69 loc) · 1.93 KB
/
Copy pathiam_codedeploy.tf
File metadata and controls
75 lines (69 loc) · 1.93 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
resource "aws_iam_role" "codedeploy" {
name = "${local.iam_role_prefix}-codedeploy-${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 = "codedeploy.amazonaws.com"
}
},
]
})
inline_policy {
name = "pipeline-artifacts-permissions"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"s3:GetObject",
"s3:GetObjectVersion"
]
Effect = "Allow"
Resource = "${local.artifact_store_bucket_arn}/${local.pipeline_artifacts_folder}/${local.deploy_output}/*"
}
]
})
}
dynamic "inline_policy" {
for_each = var.codedeploy_appspec_hooks_after_allow_traffic_arn != "" ? [true] : []
content {
name = "hooks-after-allow-traffic"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = ["lambda:InvokeFunction"]
Effect = "Allow"
Resource = var.codedeploy_appspec_hooks_after_allow_traffic_arn
}
]
})
}
}
dynamic "inline_policy" {
for_each = var.codedeploy_appspec_hooks_before_allow_traffic_arn != "" ? [true] : []
content {
name = "hooks-after-before-traffic"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = ["lambda:InvokeFunction"]
Effect = "Allow"
Resource = var.codedeploy_appspec_hooks_before_allow_traffic_arn
}
]
})
}
}
}
resource "aws_iam_role_policy_attachment" "codedeploy" {
role = aws_iam_role.codedeploy.id
policy_arn = "arn:${data.aws_partition.current.partition}:iam::aws:policy/service-role/AWSCodeDeployRoleForLambda"
}