Skip to content

Commit d9878a3

Browse files
committed
fix: Use new dedicated aws_iam_role_policy resource.
1 parent c2dd65f commit d9878a3

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

malware.tf

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@ resource "aws_iam_role" "malware" {
99
partition : data.aws_partition.current.partition
1010
region : data.aws_region.current.region
1111
})))
12+
}
1213

13-
inline_policy {
14-
name = "${local.bucket_name}-malware"
15-
policy = jsonencode(yamldecode(templatefile("${path.module}/templates/malware-policy.yaml.tftpl", {
16-
account : data.aws_caller_identity.identity.account_id
17-
bucket_arn : module.this.arn
18-
kms_key_arn : local.kms_key_arn
19-
partition : data.aws_partition.current.partition
20-
region : data.aws_region.current.region
21-
})))
22-
}
14+
resource "aws_iam_role_policy" "malware" {
15+
for_each = var.enable_malware_protection ? toset(["this"]) : toset([])
16+
17+
name = "${local.bucket_name}-malware"
18+
role = aws_iam_role.malware["this"].name
2319

20+
policy = jsonencode(yamldecode(templatefile("${path.module}/templates/malware-policy.yaml.tftpl", {
21+
account : data.aws_caller_identity.identity.account_id
22+
bucket_arn : module.this.arn
23+
kms_key_arn : local.kms_key_arn
24+
partition : data.aws_partition.current.partition
25+
region : data.aws_region.current.region
26+
})))
2427
}
2528

2629
resource "aws_guardduty_malware_protection_plan" "this" {

0 commit comments

Comments
 (0)