Skip to content

Commit 9b3f038

Browse files
committed
odin-316: only allow assume role from current account
1 parent 02dc465 commit 9b3f038

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

iam.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
data "aws_caller_identity" "current" {}
3+
24
resource "aws_iam_role" "this" {
35
name = "lambda-${var.name}"
46
assume_role_policy = jsonencode(
@@ -10,7 +12,12 @@ resource "aws_iam_role" "this" {
1012
Principal = {
1113
Service = "lambda.amazonaws.com"
1214
},
13-
Effect = "Allow"
15+
Effect = "Allow",
16+
Condition = {
17+
StringEquals = {
18+
"aws:SourceAccount" = data.aws_caller_identity.current.account_id
19+
}
20+
}
1421
}
1522
]
1623
}

0 commit comments

Comments
 (0)