diff --git a/cluster/eks.tf b/cluster/eks.tf index 1dafd75..0644201 100644 --- a/cluster/eks.tf +++ b/cluster/eks.tf @@ -2,7 +2,7 @@ module "vpc_cni_irsa" { source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks" version = "~> 5.0" - role_name = "${var.environment}-radar-base-vpc-cni-irsa" + role_name = "${var.eks_cluster_name}-vpc-cni-irsa" attach_vpc_cni_policy = true vpc_cni_enable_ipv4 = true @@ -13,14 +13,14 @@ module "vpc_cni_irsa" { } } - tags = merge(tomap({ "Name" : "radar-base-vpc-cni-irsa" }), var.common_tags) + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-vpc-cni-irsa" }), var.common_tags) } module "ebs_csi_irsa" { source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks" version = "~> 5.0" - role_name = "radar-base-ebs-csi-irsa" + role_name = "${var.eks_cluster_name}-ebs-csi-irsa" attach_ebs_csi_policy = true @@ -31,7 +31,7 @@ module "ebs_csi_irsa" { } } - tags = merge(tomap({ "Name" : "radar-base-ebs-csi-irsa" }), var.common_tags) + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-ebs-csi-irsa" }), var.common_tags) } module "eks" { diff --git a/cluster/iam.tf b/cluster/iam.tf index ed8346a..52b6a8c 100644 --- a/cluster/iam.tf +++ b/cluster/iam.tf @@ -2,7 +2,7 @@ module "allow_eks_access_iam_policy" { source = "terraform-aws-modules/iam/aws//modules/iam-policy" version = "5.15.0" - name = "${var.environment}-radar-base-allow-eks-access" + name = "${var.eks_cluster_name}-allow-eks-access" create_policy = true policy = jsonencode({ @@ -18,7 +18,7 @@ module "allow_eks_access_iam_policy" { ] }) - tags = merge(tomap({ "Name" : "radar-base-allow-eks-access" }), var.common_tags) + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-allow-eks-access" }), var.common_tags) } module "eks_admins_iam_role" { @@ -26,7 +26,7 @@ module "eks_admins_iam_role" { version = "5.15.0" role_description = "The administrative role for the EKS cluster" - role_name = "${var.environment}-radar-base-admin-role" + role_name = "${var.eks_cluster_name}-admin-role" create_role = true role_requires_mfa = false @@ -36,7 +36,7 @@ module "eks_admins_iam_role" { "arn:aws:iam::${module.vpc.vpc_owner_id}:root" ] - tags = merge(tomap({ "Name" : "radar-base-admin-role" }), var.common_tags) + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-admin-role" }), var.common_tags) } @@ -44,7 +44,7 @@ module "allow_assume_eks_admins_iam_policy" { source = "terraform-aws-modules/iam/aws//modules/iam-policy" version = "5.15.0" - name = "${var.environment}-radar-base-allow-assume-eks-admin-role" + name = "${var.eks_cluster_name}-allow-assume-eks-admin-role" create_policy = true policy = jsonencode({ @@ -60,26 +60,26 @@ module "allow_assume_eks_admins_iam_policy" { ] }) - tags = merge(tomap({ "Name" : "radar-base-allow-assume-eks-admin-role" }), var.common_tags) + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-allow-assume-eks-admin-role" }), var.common_tags) } module "eks_admins_iam_group" { source = "terraform-aws-modules/iam/aws//modules/iam-group-with-policies" version = "5.15.0" - name = "${var.environment}-radar-base-eks-admin-group" + name = "${var.eks_cluster_name}-eks-admin-group" attach_iam_self_management_policy = false create_group = true group_users = var.eks_admins_group_users custom_group_policy_arns = [module.allow_assume_eks_admins_iam_policy.arn] - tags = merge(tomap({ "Name" : "radar-base-eks-admin-group" }), var.common_tags) + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-eks-admin-group" }), var.common_tags) } module "iam_user" { source = "terraform-aws-modules/iam/aws//modules/iam-user" - name = "${var.environment}-radar-base-ecr-readonly-user" + name = "${var.eks_cluster_name}-ecr-readonly-user" create_iam_user_login_profile = false create_iam_access_key = true force_destroy = false @@ -88,11 +88,11 @@ module "iam_user" { "arn:aws:iam::aws:policy/AmazonElasticContainerRegistryPublicReadOnly", ] - tags = merge(tomap({ "Name" : "radar-base-ecr-readonly-user" }), var.common_tags) + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-ecr-readonly-user" }), var.common_tags) } resource "aws_iam_policy" "s3_access" { - name = "radar-base-${var.environment}-s3-access-policy" + name = "${var.eks_cluster_name}-s3-access-policy" path = "/eks/" policy = jsonencode({ @@ -107,17 +107,19 @@ resource "aws_iam_policy" "s3_access" { "s3:DeleteObject" ] Resource = [ - "arn:aws:s3:::radar-base-${var.environment}-intermediate-output-storage/*", - "arn:aws:s3:::radar-base-${var.environment}-output-storage/*", - "arn:aws:s3:::radar-base-${var.environment}-velero-backups/*", + "arn:aws:s3:::${var.eks_cluster_name}-intermediate-output-storage/*", + "arn:aws:s3:::${var.eks_cluster_name}-output-storage/*", + "arn:aws:s3:::${var.eks_cluster_name}-velero-backups/*", ] } ] }) + + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-s3-access-policy" }), var.common_tags) } resource "aws_iam_policy" "ecr_access" { - name = "radar-base-${var.environment}-ecr-access-policy" + name = "${var.eks_cluster_name}-ecr-access-policy" policy = jsonencode({ Version = "2012-10-17" @@ -143,11 +145,11 @@ resource "aws_iam_policy" "ecr_access" { ] }) - tags = merge(tomap({ "Name" : "radar-base-ecr-access-policy" }), var.common_tags) + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-ecr-access-policy" }), var.common_tags) } resource "aws_iam_policy" "ecr_pull_through_cache" { - name = "radar-base-${var.environment}-ecr-pull-through-cache-policy" + name = "${var.eks_cluster_name}-ecr-pull-through-cache-policy" policy = jsonencode({ Version = "2012-10-17" @@ -164,5 +166,5 @@ resource "aws_iam_policy" "ecr_pull_through_cache" { ] }) - tags = merge(tomap({ "Name" : "radar-base-ecr-pull-through-cache-policy" }), var.common_tags) + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-ecr-pull-through-cache-policy" }), var.common_tags) } diff --git a/cluster/variables.tf b/cluster/variables.tf index 484041e..d2f9882 100644 --- a/cluster/variables.tf +++ b/cluster/variables.tf @@ -39,7 +39,7 @@ variable "common_tags" { type = map(string) description = "Common tags associated to resources created" default = { - Project = "radar-base-development" + Project = "radar-base" Environment = "dev" } } diff --git a/config/karpenter.tf b/config/karpenter.tf index a1fabea..c444128 100644 --- a/config/karpenter.tf +++ b/config/karpenter.tf @@ -10,7 +10,7 @@ module "karpenter" { create_iam_role = false iam_role_arn = data.aws_eks_node_group.worker.node_role_arn - tags = merge(tomap({ "Name" : "radar-base-karpenter" }), var.common_tags) + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-karpenter" }), var.common_tags) } resource "helm_release" "karpenter" { diff --git a/config/msk.tf b/config/msk.tf index 027a6ae..29f7c7f 100644 --- a/config/msk.tf +++ b/config/msk.tf @@ -1,5 +1,5 @@ resource "aws_iam_role" "msk_role" { - name = "${var.environment}-msk-role" + name = "${var.eks_cluster_name}-msk-role" assume_role_policy = jsonencode({ Version = "2012-10-17" @@ -14,7 +14,7 @@ resource "aws_iam_role" "msk_role" { ] }) - tags = merge(tomap({ "Name" : "msk-role" }), var.common_tags) + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-msk-role" }), var.common_tags) } resource "aws_iam_role_policy_attachment" "msk_policy_attachment" { @@ -23,7 +23,7 @@ resource "aws_iam_role_policy_attachment" "msk_policy_attachment" { } resource "aws_security_group" "msk_cluster_access" { - name_prefix = "${var.environment}-radar-base-msk-" + name_prefix = "${var.eks_cluster_name}-msk-" description = "This security group is for accessing the MSK cluster" vpc_id = data.aws_vpc.main.id @@ -41,12 +41,12 @@ resource "aws_security_group" "msk_cluster_access" { security_groups = [data.aws_security_group.node.id] } - tags = merge(tomap({ "Name" : "msk-cluster-access-sg" }), var.common_tags) + tags = merge(tomap({ "Name" : "${var.eks_cluster_name}-msk-cluster-access-sg" }), var.common_tags) } resource "aws_msk_configuration" "msk_configuration" { kafka_versions = [var.kafka_version] - name = "radar-base-${var.environment}-msk-configuration" + name = "${var.eks_cluster_name}-msk-configuration" server_properties = <