Skip to content

Commit

Permalink
feat: Added AccessedViaMountTarget condition for deny_nonsecure_trans…
Browse files Browse the repository at this point in the history
…port (#21)
  • Loading branch information
antonbabenko committed Jan 12, 2024
1 parent fdc7231 commit 543f54c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.83.5
rev: v1.86.0
hooks:
- id: terraform_fmt
- id: terraform_validate
Expand Down
26 changes: 26 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,32 @@ data "aws_iam_policy_document" "policy" {
}
}
}

dynamic "statement" {
for_each = var.deny_nonsecure_transport ? [1] : []

content {
sid = "NonSecureTransportAccessedViaMountTarget"
effect = "Allow"
actions = [
"elasticfilesystem:ClientRootAccess",
"elasticfilesystem:ClientWrite",
"elasticfilesystem:ClientMount"
]
resources = [aws_efs_file_system.this[0].arn]

principals {
type = "AWS"
identifiers = ["*"]
}

condition {
test = "Bool"
variable = "elasticfilesystem:AccessedViaMountTarget"
values = ["true"]
}
}
}
}

resource "aws_efs_file_system_policy" "this" {
Expand Down

0 comments on commit 543f54c

Please sign in to comment.