Skip to content

Commit

Permalink
feat: Add SourceArn condition to Fargate profile trust policy (#3039)
Browse files Browse the repository at this point in the history
feat: add `SourceArn` condition to fargate-profile assume_role_policy
  • Loading branch information
cpboyd authored May 16, 2024
1 parent 92fca6f commit a070d7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/fargate-profile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions modules/fargate-profile/main.tf
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}/*",
]
}
}
}

Expand Down

0 comments on commit a070d7b

Please sign in to comment.