-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam.tf
78 lines (64 loc) · 1.86 KB
/
iam.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
module "allow_eks_access_iam_policy" {
source = "terraform-aws-modules/iam/aws//modules/iam-policy"
version = "5.3.1"
name = "allow-eks-access"
create_policy = true
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"eks:DescribeCluster",
]
Effect = "Allow"
Resource = "*"
},
]
})
}
module "eks_admins_iam_role" {
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-role"
version = "5.3.1"
role_name = "eks-admin"
create_role = true
role_requires_mfa = false
custom_role_policy_arns = [module.allow_eks_access_iam_policy.arn]
trusted_role_arns = [
"arn:aws:iam::${aws_vpc.project_vpc.owner_id}:root"
]
}
module "user1_iam_user" {
source = "terraform-aws-modules/iam/aws//modules/iam-user"
version = "5.3.1"
name = "user1"
create_iam_access_key = false
create_iam_user_login_profile = false
force_destroy = true
}
module "allow_assume_eks_admins_iam_policy" {
source = "terraform-aws-modules/iam/aws//modules/iam-policy"
version = "5.3.1"
name = "allow-assume-eks-admin-iam-role"
create_policy = true
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Action = [
"sts:AssumeRole",
]
Effect = "Allow"
Resource = module.eks_admins_iam_role.iam_role_arn
},
]
})
}
module "eks_admins_iam_group" {
source = "terraform-aws-modules/iam/aws//modules/iam-group-with-policies"
version = "5.3.1"
name = "eks-admin"
attach_iam_self_management_policy = false
create_group = true
group_users = [module.user1_iam_user.iam_user_name]
custom_group_policy_arns = [module.allow_assume_eks_admins_iam_policy.arn]
}