Skip to content

Commit

Permalink
Update main.tf
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoclessa authored Sep 26, 2023
1 parent f51c489 commit 765d021
Showing 1 changed file with 5 additions and 28 deletions.
33 changes: 5 additions & 28 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ data "aws_iam_policy" "ebs_csi_policy" {

data "aws_eks_cluster" "eks" {
name = local.config.cluster_name
depends_on = [module.cluster]
}

module "cluster" {
Expand All @@ -20,32 +21,7 @@ module "cluster" {
cluster_enabled_log_types = try(local.config.cluster_enabled_log_types, [""])
aws_availability_zones = try(local.config.aws_availability_zones, [""])
}

module "kubernetes" {
source = "gitlab.com/vkpr/terraform-kubernetes-rbac/kubernetes"
version = "~> 1.1.0"

users_list = local.config.users_list
cluster_endpoint = module.cluster.cluster_endpoint
cluster_ca_certificate = module.cluster.cluster_certificate_authority_data
cluster_access_token = module.cluster.kubeconfig_token

depends_on = [module.cluster]
}

module "kubeconfig" {
source = "gitlab.com/vkpr/terraform-kubernetes-kubeconfig/kubernetes"
version = "~> 1.1.0"

users_list = local.config.users_list
cluster_name = local.config.cluster_name
cluster_endpoint = module.cluster.cluster_endpoint
cluster_ca_certificate = module.cluster.cluster_certificate_authority_data
cluster_access_token = module.kubernetes.secrets_access_tokens

depends_on = [module.kubernetes]
}


data "aws_eks_cluster" "cluster" {
name = local.config.cluster_name
depends_on = [module.cluster]
Expand Down Expand Up @@ -73,16 +49,17 @@ module "irsa-ebs-csi" {
version = "4.7.0"

create_role = true
role_name = "AmazonEKSTFEBSCSIRole-$local.config.cluster_name"
role_name = "AmazonEKSTFEBSCSIRole-Platform"
provider_url = replace(data.aws_eks_cluster.eks.identity.0.oidc.0.issuer, "https://", "")
role_policy_arns = [data.aws_iam_policy.ebs_csi_policy.arn]
oidc_fully_qualified_subjects = ["system:serviceaccount:kube-system:ebs-csi-controller-sa"]
depends_on = [module.cluster]

}

resource "aws_eks_addon" "ebs-csi" {
cluster_name = local.config.cluster_name
addon_name = "aws-ebs-csi-driver"
addon_version = "v1.5.2-eksbuild.1"
service_account_role_arn = module.irsa-ebs-csi.iam_role_arn
tags = {
"eks_addon" = "ebs-csi"
Expand Down

0 comments on commit 765d021

Please sign in to comment.