Skip to content

Commit a070d7b

Browse files
authored
feat: Add SourceArn condition to Fargate profile trust policy (#3039)
feat: add `SourceArn` condition to fargate-profile assume_role_policy
1 parent 92fca6f commit a070d7b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

modules/fargate-profile/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ No modules.
5252
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
5353
| [aws_iam_policy_document.assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
5454
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
55+
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
5556

5657
## Inputs
5758

modules/fargate-profile/main.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
data "aws_partition" "current" {}
22
data "aws_caller_identity" "current" {}
3+
data "aws_region" "current" {}
34

45
locals {
56
create_iam_role = var.create && var.create_iam_role
@@ -30,6 +31,15 @@ data "aws_iam_policy_document" "assume_role_policy" {
3031
type = "Service"
3132
identifiers = ["eks-fargate-pods.amazonaws.com"]
3233
}
34+
35+
condition {
36+
test = "ArnLike"
37+
variable = "aws:SourceArn"
38+
39+
values = [
40+
"arn:${data.aws_partition.current.partition}:eks:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:fargateprofile/${var.cluster_name}/*",
41+
]
42+
}
3343
}
3444
}
3545

0 commit comments

Comments
 (0)