diff --git a/modules/vpc-network/main.tf b/modules/vpc-network/main.tf index 5fb26b2..a12d87e 100644 --- a/modules/vpc-network/main.tf +++ b/modules/vpc-network/main.tf @@ -53,7 +53,15 @@ resource "google_compute_subnetwork" "vpc_subnetwork_public" { ) } - enable_flow_logs = var.enable_flow_logging + dynamic "log_config" { + for_each = var.log_config == null ? [] : list(var.log_config) + + content { + aggregation_interval = var.log_config.aggregation_interval + flow_sampling = var.log_config.flow_sampling + metadata = var.log_config.metadata + } + } } resource "google_compute_router_nat" "vpc_nat" { @@ -101,7 +109,15 @@ resource "google_compute_subnetwork" "vpc_subnetwork_private" { ) } - enable_flow_logs = var.enable_flow_logging + dynamic "log_config" { + for_each = var.log_config == null ? [] : list(var.log_config) + + content { + aggregation_interval = var.log_config.aggregation_interval + flow_sampling = var.log_config.flow_sampling + metadata = var.log_config.metadata + } + } } # --------------------------------------------------------------------------------------------------------------------- diff --git a/modules/vpc-network/variables.tf b/modules/vpc-network/variables.tf index 10eb807..56187fe 100644 --- a/modules/vpc-network/variables.tf +++ b/modules/vpc-network/variables.tf @@ -59,10 +59,14 @@ variable "secondary_cidr_subnetwork_spacing" { default = 0 } -variable "enable_flow_logging" { - description = "Whether to enable VPC Flow Logs being sent to Stackdriver (https://cloud.google.com/vpc/docs/using-flow-logs)" - type = bool - default = true +variable "log_config" { + description = "The logging options for the subnetwork flow logs." + type = object({ + aggregation_interval = string + flow_sampling = number + metadata = string + }) + default = null } variable allowed_public_restricted_subnetworks {