-
Notifications
You must be signed in to change notification settings - Fork 10
/
users.tf
99 lines (84 loc) · 2.1 KB
/
users.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
97
resource "aws_iam_user" "ci_user" {
name = "${module.labels.id}-ci"
tags = module.labels.tags
}
resource "aws_iam_user_policy_attachment" "ci_user_ecr" {
user = aws_iam_user.ci_user.name
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess"
}
data "aws_iam_policy_document" "ci_user" {
statement {
actions = [
"ecs:UpdateService",
"ecs:DescribeTaskDefinition",
"ecs:RegisterTaskDefinition",
"ecs:DescribeServices",
"cloudwatch:PutDashboard",
"cloudwatch:GetDashboard"
]
resources = [
"*",
]
}
statement {
actions = [
"s3:ListBucket",
"s3:PutObject"
]
resources = [
aws_s3_bucket.assets.arn,
format("%s/*", aws_s3_bucket.assets.arn)
]
}
statement {
actions = [
"route53:GetChange"
]
resources = [
"*"
]
}
}
data "aws_iam_policy_document" "ci_user_lambda" {
statement {
actions = [
"lambda:UpdateFunctionCode",
"lambda:ListAliases",
"lambda:ListVersionsByFunction",
"lambda:UpdateAlias"
]
resources = [
"*",
]
}
}
data "aws_iam_policy_document" "ci_user_pass_role" {
statement {
actions = [
"iam:PassRole"
]
resources = [
aws_iam_role.admin_ecs_task_role.arn,
aws_iam_role.admin_ecs_task_execution.arn,
aws_iam_role.api_ecs_task_role.arn,
aws_iam_role.api_ecs_task_execution.arn,
aws_iam_role.push_ecs_task_role.arn,
aws_iam_role.push_ecs_task_execution.arn
]
}
}
resource "aws_iam_user_policy" "ci_user_general" {
name = "${module.labels.id}-ci-user"
user = aws_iam_user.ci_user.name
policy = data.aws_iam_policy_document.ci_user.json
}
resource "aws_iam_user_policy" "ci_user_lambda" {
name = "${module.labels.id}-ci-user_lambda"
user = aws_iam_user.ci_user.name
policy = data.aws_iam_policy_document.ci_user_lambda.json
}
resource "aws_iam_user_policy" "ci_user_pass_role" {
name = "${module.labels.id}-ci-user_pass_role"
user = aws_iam_user.ci_user.name
policy = data.aws_iam_policy_document.ci_user_pass_role.json
}