github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/avd_docs/google/gke/AVD-GCP-0061/Terraform.md (about) 1 2 Enable master authorized networks 3 4 ```hcl 5 resource "google_service_account" "default" { 6 account_id = "service-account-id" 7 display_name = "Service Account" 8 } 9 10 resource "google_container_cluster" "primary" { 11 name = "my-gke-cluster" 12 location = "us-central1" 13 14 # We can't create a cluster with no node pool defined, but we want to only use 15 # separately managed node pools. So we create the smallest possible default 16 # node pool and immediately delete it. 17 remove_default_node_pool = true 18 initial_node_count = 1 19 master_authorized_networks_config { 20 cidr_blocks { 21 cidr_block = "10.10.128.0/24" 22 display_name = "internal" 23 } 24 } 25 } 26 27 resource "google_container_node_pool" "primary_preemptible_nodes" { 28 name = "my-node-pool" 29 location = "us-central1" 30 cluster = google_container_cluster.primary.name 31 node_count = 1 32 33 node_config { 34 preemptible = true 35 machine_type = "e2-medium" 36 37 # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. 38 service_account = google_service_account.default.email 39 oauth_scopes = [ 40 "https://www.googleapis.com/auth/cloud-platform" 41 ] 42 } 43 } 44 45 ``` 46 47 #### Remediation Links 48 - https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster# 49