Skip to content

Commit

Permalink
Added validation logic for log_config section
Browse files Browse the repository at this point in the history
  • Loading branch information
horiagunica committed Oct 8, 2024
1 parent c4be263 commit 45a5a22
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/vpc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ variable "subnetworks" {
filter_expr = optional(string)
}))
}))
validation {
condition = alltrue([
for subnet in var.subnetworks :
subnet.log_config != null ? (
(subnet.log_config.aggregation_interval != null && can(regex("^INTERVAL_(5_SEC|30_SEC|1_MIN|5_MIN|10_MIN|15_MIN)$", subnet.log_config.aggregation_interval)) ? true : false) &&
(subnet.log_config.metadata != null && can(regex("^(EXCLUDE_ALL_METADATA|INCLUDE_ALL_METADATA|CUSTOM_METADATA)$", subnet.log_config.metadata)) ? true : false)
) : true
])
error_message = "If log_config is specified, aggregation_interval must be one of INTERVAL_5_SEC, INTERVAL_30_SEC, INTERVAL_1_MIN, INTERVAL_5_MIN, INTERVAL_10_MIN, INTERVAL_15_MIN, and metadata must be one of EXCLUDE_ALL_METADATA, INCLUDE_ALL_METADATA, or CUSTOM_METADATA."
}
}

variable "firewall_rules" {
Expand Down

0 comments on commit 45a5a22

Please sign in to comment.