Skip to content

Commit

Permalink
Update Fargate Profile module to create new execution role
Browse files Browse the repository at this point in the history
  • Loading branch information
loshan20011 committed Jan 9, 2025
1 parent 4cd450f commit c741144
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion modules/aws/EKS-Fargate-Profile/eks_fargate_profile.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
resource "aws_eks_fargate_profile" "eks_fargate_profile" {
cluster_name = var.eks_cluster_name
fargate_profile_name = var.fargate_profile_name
pod_execution_role_arn = var.fargate_iam_role_arn == null ? aws_iam_role.iam_role[0].arn : var.fargate_iam_role_arn
pod_execution_role_arn = aws_iam_role.iam_role.arn
subnet_ids = var.subnet_ids
tags = var.tags

Expand Down
5 changes: 2 additions & 3 deletions modules/aws/EKS-Fargate-Profile/iam_role.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
# --------------------------------------------------------------------------------------

resource "aws_iam_role" "iam_role" {
count = var.fargate_iam_role_arn != null ? 0 : 1
name = join("-", [var.eks_cluster_name, var.fargate_profile_name, "eks-fargate-profile-iam-role"])
name = join("-", [var.eks_cluster_name, var.fargate_profile_name, "eks-fargate-profile-iam-role"])

assume_role_policy = jsonencode({
Statement = [{
Expand All @@ -37,7 +36,7 @@ resource "aws_iam_role" "iam_role" {

resource "aws_iam_role_policy_attachment" "amazon_eks_fargate_pod_execution_role_policy" {
policy_arn = "arn:aws:iam::aws:policy/AmazonEKSFargatePodExecutionRolePolicy"
role = aws_iam_role.iam_role[0].name
role = aws_iam_role.iam_role.name

depends_on = [
aws_iam_role.iam_role
Expand Down
6 changes: 0 additions & 6 deletions modules/aws/EKS-Fargate-Profile/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
#
# --------------------------------------------------------------------------------------

variable "fargate_iam_role_arn" {
description = "IAM role ARN to be associated with the fargate"
type = string
default = null
}

variable "eks_cluster_name" {
description = "Name of the EKS cluster"
type = string
Expand Down

0 comments on commit c741144

Please sign in to comment.