@@ -50,6 +50,8 @@ provider-selections: ${data.external.iac_tooling_version.result["provider_select
5050outdated: ${ data . external . iac_tooling_version . result [" terraform_outdated" ]}
5151EOT
5252 }
53+
54+ depends_on = [module . kubeconfig . kube_config ]
5355}
5456
5557# EKS Provider
@@ -91,7 +93,7 @@ module "vpc" {
9193# EKS Setup - https://github.com/terraform-aws-modules/terraform-aws-eks
9294module "eks" {
9395 source = " terraform-aws-modules/eks/aws"
94- version = " ~> 19 .0"
96+ version = " ~> 20 .0"
9597 cluster_name = local. cluster_name
9698 cluster_version = var. kubernetes_version
9799 cluster_enabled_log_types = [] # disable cluster control plan logging
@@ -163,6 +165,36 @@ module "eks" {
163165 create_iam_role = var. cluster_iam_role_arn == null ? true : false
164166 iam_role_arn = var. cluster_iam_role_arn
165167
168+ # Cluster access entry
169+ # To add the current caller identity as an administrator
170+ enable_cluster_creator_admin_permissions = true
171+
172+ access_entries = {
173+ # access entry with cluster and namespace scoped policies
174+ cluster_creator = {
175+ kubernetes_groups = [" rbac.authorization.k8s.io" ]
176+ principal_arn = data.aws_caller_identity.terraform.arn
177+ user_name = local.aws_caller_identity_user_name
178+ type = " STANDARD"
179+
180+ policy_associations = {
181+ cluster_creator_assoc = {
182+ policy_arn = " arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy"
183+ access_scope = {
184+ type = " cluster"
185+ }
186+ },
187+ namespace_creator_assoc = {
188+ policy_arn = " arn:aws:eks::aws:cluster-access-policy/AmazonEKSAdminPolicy"
189+ access_scope = {
190+ type = " namespace"
191+ namespaces = [" kube-system" ]
192+ }
193+ }
194+ },
195+ },
196+ }
197+
166198 iam_role_additional_policies = {
167199 " additional" : " arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
168200 }
@@ -222,7 +254,7 @@ module "kubeconfig" {
222254 ca_crt = local. kubeconfig_ca_cert
223255 sg_id = local. cluster_security_group_id
224256
225- depends_on = [module . eks . cluster_name ] # The name/id of the EKS cluster. Will block on cluster creation until the cluster is really ready.
257+ depends_on = [module . eks ] # Will block on EKS cluster creation until the cluster is completely ready.
226258}
227259
228260# Normally, the use of local-exec below is avoided. It is used here to patch the gp2 storage class as the default storage class for EKS 1.30 and later clusters.
@@ -233,7 +265,7 @@ resource "terraform_data" "run_command" {
233265 command = " kubectl --kubeconfig=${ local . kubeconfig_path } patch storageclass gp2 --patch '{\" metadata\" : {\" annotations\" :{\" storageclass.kubernetes.io/is-default-class\" :\" true\" }}}' "
234266 }
235267
236- depends_on = [module . kubeconfig ]
268+ depends_on = [module . kubeconfig . kube_config ]
237269}
238270
239271# Database Setup - https://registry.terraform.io/modules/terraform-aws-modules/rds/aws/6.2.0
0 commit comments