Repository navigation
tfsec is not evaluating my variables #2090
Replies: 1 comment
|
tfsec's static analysis engine has limited support for resolving values through complex nested object types. When it sees This happens even when there's a Workaround 1: Pass a var-file at scan time Create a tfsec . --var-file tfsec.tfvars# tfsec.tfvars
password_policy_definition = {
tagging_config = { ... }
password_config = {
minimum_password_length = 14
password_reuse_prevention = 5
require_lowercase_characters = true
# ...
}
}Workaround 2: Inline ignore on specific checks If you know the module's defaults always meet the policy, suppress the specific check: resource "aws_iam_account_password_policy" "default" {
#tfsec:ignore:aws-iam-enforce-mfa
minimum_password_length = var.password_policy_definition.minimum_password_length
...
}Workaround 3: Migrate to trivy tfsec is now deprecated — it's been absorbed into trivy config . --tf-vars tfsec.tfvarsThe underlying limitation (static analysis can't always evaluate runtime values through complex object graphs) still applies, but trivy's resolution is more complete than tfsec's was. |
Uh oh!
There was an error while loading. Please reload this page.
Here is my module:
resource "aws_iam_account_password_policy" "default" {
provider = aws.src
count = var.password_policy_definition.create_policy ? 1 : 0
minimum_password_length = var.password_policy_definition.minimum_password_length
password_reuse_prevention = var.password_policy_definition.password_reuse_prevention
require_lowercase_characters = var.password_policy_definition.require_lowercase_characters
require_numbers = var.password_policy_definition.require_numbers
require_uppercase_characters = var.password_policy_definition.require_uppercase_characters
require_symbols = var.password_policy_definition.require_symbols
allow_users_to_change_password = var.password_policy_definition.allow_users_to_change_password
max_password_age = var.password_policy_definition.max_password_age
hard_expiry = var.password_policy_definition.hard_expiry
}
here is my variable definition:
variable "password_policy_definition" {
description = <<-EOF
Variable definition for password_policy_definition configuration options, including:
EOF
type = object({
tagging_config = object({
environment_name = string
tag_owner = string
tag_project = string
tag_feature = string
})
password_config = object({
create_policy = bool
max_password_age = number
minimum_password_length = number
password_reuse_prevention = number
require_lowercase_characters = bool
require_numbers = bool
require_uppercase_characters = bool
require_symbols = bool
allow_users_to_change_password = bool
hard_expiry = bool
})
})
default = {
tagging_config = {
environment_name = "Test"
tag_owner = "Sample Company"
tag_project = "Sample Project"
tag_feature = "IAM Password Policy"
}
password_config = {
create_policy = true
max_password_age = 90
minimum_password_length = 14
password_reuse_prevention = 5
require_lowercase_characters = true
require_numbers = true
require_uppercase_characters = true
require_symbols = true
allow_users_to_change_password = true
hard_expiry = false
}
}
}
tfsec is throwing errors and is not SEEING my default variables setting, but when I run my Terraform apply, all the values are set correctly in AWS.
All reactions