From df1cf5bb5c9d501b860c2937e5b54f08a3d7ffda Mon Sep 17 00:00:00 2001 From: Ranika Date: Fri, 8 Mar 2024 11:25:51 +0530 Subject: [PATCH] Update IAM role names --- modules/aws/EKS-Cluster/data.tf | 4 ++-- modules/aws/EKS-Cluster/iam_role.tf | 22 +++++++++++----------- modules/aws/EKS-Cluster/outputs.tf | 10 +++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/aws/EKS-Cluster/data.tf b/modules/aws/EKS-Cluster/data.tf index 178ba41..a4efb5c 100644 --- a/modules/aws/EKS-Cluster/data.tf +++ b/modules/aws/EKS-Cluster/data.tf @@ -57,7 +57,7 @@ data "aws_iam_policy_document" "cluster_lb_sts_policy" { ] } -data "aws_iam_policy_document" "cluster_container_cloudwatch_streamer_sts_policy" { +data "aws_iam_policy_document" "cluster_container_cloudwatch_fluent_bit_agent_sts_policy" { statement { actions = ["sts:AssumeRoleWithWebIdentity"] effect = "Allow" @@ -77,7 +77,7 @@ data "aws_iam_policy_document" "cluster_container_cloudwatch_streamer_sts_policy ] } -data "aws_iam_policy_document" "cluster_cloudwatch_sts_policy" { +data "aws_iam_policy_document" "cluster_cloudwatch_agent_sts_policy" { statement { actions = ["sts:AssumeRoleWithWebIdentity"] effect = "Allow" diff --git a/modules/aws/EKS-Cluster/iam_role.tf b/modules/aws/EKS-Cluster/iam_role.tf index 0d55e88..45223cd 100644 --- a/modules/aws/EKS-Cluster/iam_role.tf +++ b/modules/aws/EKS-Cluster/iam_role.tf @@ -376,21 +376,21 @@ resource "aws_iam_role_policy_attachment" "cluster_loadbalancer_policy_attach" { } # IAM Role for CloudWatch Agents -resource "aws_iam_role" "cluster_container_cloudwatch_streamer_role" { - assume_role_policy = data.aws_iam_policy_document.cluster_container_cloudwatch_streamer_sts_policy.json +resource "aws_iam_role" "cluster_container_cloudwatch_fluent_bit_agent_role" { + assume_role_policy = data.aws_iam_policy_document.cluster_container_cloudwatch_fluent_bit_agent_sts_policy.json name = join("-", [var.project, var.application, var.environment, var.region, "eks-cluster-ccw-iam-role"]) depends_on = [ - data.aws_iam_policy_document.cluster_container_cloudwatch_streamer_sts_policy + data.aws_iam_policy_document.cluster_container_cloudwatch_fluent_bit_agent_sts_policy ] } -resource "aws_iam_role_policy_attachment" "cluster_container_cloudwatch_streamer_policy_attach" { - role = aws_iam_role.cluster_container_cloudwatch_streamer_role.name +resource "aws_iam_role_policy_attachment" "cluster_container_cloudwatch_fluent_bit_agent_policy_attach" { + role = aws_iam_role.cluster_container_cloudwatch_fluent_bit_agent_role.name policy_arn = "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy" depends_on = [ - aws_iam_role.cluster_container_cloudwatch_streamer_role + aws_iam_role.cluster_container_cloudwatch_fluent_bit_agent_role ] } @@ -437,8 +437,8 @@ resource "aws_iam_role_policy_attachment" "cluster_efs_csi_driver_role_policy_at } # CloudWatch Agent Policy -resource "aws_iam_role" "cluster_cloudwatch_role" { - assume_role_policy = data.aws_iam_policy_document.cluster_cloudwatch_sts_policy.json +resource "aws_iam_role" "cluster_cloudwatch_agent_role" { + assume_role_policy = data.aws_iam_policy_document.cluster_cloudwatch_agent_sts_policy.json name = join("-", [var.project, var.application, var.environment, var.region, "eks-cluster-cw-iam-role"]) depends_on = [ @@ -446,11 +446,11 @@ resource "aws_iam_role" "cluster_cloudwatch_role" { ] } -resource "aws_iam_role_policy_attachment" "cluster_cloudwatch_role_policy_attach" { - role = aws_iam_role.cluster_cloudwatch_role.name +resource "aws_iam_role_policy_attachment" "cluster_cloudwatch_agent_role_policy_attach" { + role = aws_iam_role.cluster_cloudwatch_agent_role.name policy_arn = "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy" depends_on = [ - aws_iam_role.cluster_cloudwatch_role + aws_iam_role.cluster_cloudwatch_agent_role ] } diff --git a/modules/aws/EKS-Cluster/outputs.tf b/modules/aws/EKS-Cluster/outputs.tf index 1be2c75..baf2ae4 100644 --- a/modules/aws/EKS-Cluster/outputs.tf +++ b/modules/aws/EKS-Cluster/outputs.tf @@ -29,13 +29,13 @@ output "lb_role_arn" { value = aws_iam_role.cluster_loadbalancer_role.arn depends_on = [aws_iam_role.cluster_loadbalancer_role] } -output "cloudwatch_streamer_role_arn" { - value = aws_iam_role.cluster_container_cloudwatch_streamer_role.arn - depends_on = [aws_iam_role.cluster_container_cloudwatch_streamer_role] +output "cloudwatch_fluent_bit_agent_role_arn" { + value = aws_iam_role.cluster_container_cloudwatch_fluent_bit_agent_role.arn + depends_on = [aws_iam_role.cluster_container_cloudwatch_fluent_bit_agent_role] } output "cloudwatch_agent_role_arn" { - value = aws_iam_role.cluster_cloudwatch_role.arn - depends_on = [aws_iam_role.cluster_cloudwatch_role] + value = aws_iam_role.cluster_cloudwatch_agent_role.arn + depends_on = [aws_iam_role.cluster_cloudwatch_agent_role] } output "ebs_csi_driver_role_arn" { value = var.enable_ebs_csi_driver ? aws_iam_role.cluster_ebs_csi_driver_role[0].arn : null