{% set config = merged_configs.get('google_compute_router_nat', {}) %}
# Compliance: {{ compliance_comments.get('google_compute_router_nat', []) | join(', ') }}
resource "google_compute_router_nat" "main" {
  name    = "{{ config.get('name', '${var.project_id}-nat') }}"
  project = var.project_id
  region  = var.region
  router  = google_compute_router.main.name

  nat_ip_allocate_option             = "{{ config.get('nat_ip_allocate_option', 'AUTO_ONLY') }}"
  source_subnetwork_ip_ranges_to_nat = "{{ config.get('source_subnetwork_ip_ranges_to_nat', 'ALL_SUBNETWORKS_ALL_IP_RANGES') }}"

  log_config {
    enable = {{ config.get('log_enable', true) | lower }}
    filter = "{{ config.get('log_filter', 'ERRORS_ONLY') }}"
  }

  min_ports_per_vm                    = {{ config.get('min_ports_per_vm', 64) }}
  enable_endpoint_independent_mapping = {{ config.get('enable_endpoint_independent_mapping', false) | lower }}
}
