{% set config = merged_configs.get('google_container_node_pool', {}) %}
# Compliance: {{ compliance_comments.get('google_container_node_pool', []) | join(', ') }}
resource "google_container_node_pool" "main" {
  name     = "{{ config.get('name', 'default-pool') }}"
  project  = var.project_id
  location = var.region
  cluster  = google_container_cluster.main.name

  initial_node_count = {{ config.get('initial_node_count', 1) }}

  autoscaling {
    min_node_count = {{ config.get('min_node_count', 1) }}
    max_node_count = {{ config.get('max_node_count', 3) }}
  }

  management {
    auto_repair  = {{ config.get('auto_repair', true) | lower }}
    auto_upgrade = {{ config.get('auto_upgrade', true) | lower }}
  }

  node_config {
    machine_type    = "{{ config.get('machine_type', 'e2-standard-4') }}"
    disk_size_gb    = {{ config.get('disk_size_gb', 100) }}
    disk_type       = "{{ config.get('disk_type', 'pd-standard') }}"
    image_type      = "{{ config.get('image_type', 'COS_CONTAINERD') }}"
    service_account = "{{ config.get('service_account', '') }}"
    oauth_scopes    = ["https://www.googleapis.com/auth/cloud-platform"]

    shielded_instance_config {
      enable_secure_boot          = {{ config.get('enable_secure_boot', true) | lower }}
      enable_integrity_monitoring = {{ config.get('enable_integrity_monitoring', true) | lower }}
    }

    metadata = {
      disable-legacy-endpoints = "true"
    }
  }
}
