diff --git a/modules/fargate-profile/README.md b/modules/fargate-profile/README.md index 0ec6ea0e10..072c2f2e33 100644 --- a/modules/fargate-profile/README.md +++ b/modules/fargate-profile/README.md @@ -52,6 +52,7 @@ No modules. | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | | [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | | [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source | +| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | ## Inputs diff --git a/modules/fargate-profile/main.tf b/modules/fargate-profile/main.tf index 7611e22014..1e2cf60024 100644 --- a/modules/fargate-profile/main.tf +++ b/modules/fargate-profile/main.tf @@ -1,5 +1,6 @@ data "aws_partition" "current" {} data "aws_caller_identity" "current" {} +data "aws_region" "current" {} locals { create_iam_role = var.create && var.create_iam_role @@ -30,6 +31,15 @@ data "aws_iam_policy_document" "assume_role_policy" { type = "Service" identifiers = ["eks-fargate-pods.amazonaws.com"] } + + condition { + test = "ArnLike" + variable = "aws:SourceArn" + + values = [ + "arn:${data.aws_partition.current.partition}:eks:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:fargateprofile/${var.cluster_name}/*", + ] + } } }