github.com/khulnasoft-lab/defsec@v1.0.5-0.20230827010352-5e9f46893d95/rules/cloud/policies/google/gke/enable_master_networks.tf.go (about) 1 package gke 2 3 var terraformEnableMasterNetworksGoodExamples = []string{ 4 ` 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 var terraformEnableMasterNetworksBadExamples = []string{ 48 ` 49 resource "google_service_account" "default" { 50 account_id = "service-account-id" 51 display_name = "Service Account" 52 } 53 54 resource "google_container_cluster" "primary" { 55 name = "my-gke-cluster" 56 location = "us-central1" 57 58 # We can't create a cluster with no node pool defined, but we want to only use 59 # separately managed node pools. So we create the smallest possible default 60 # node pool and immediately delete it. 61 remove_default_node_pool = true 62 initial_node_count = 1 63 } 64 65 resource "google_container_node_pool" "primary_preemptible_nodes" { 66 name = "my-node-pool" 67 location = "us-central1" 68 cluster = google_container_cluster.primary.name 69 node_count = 1 70 71 node_config { 72 preemptible = true 73 machine_type = "e2-medium" 74 75 # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. 76 service_account = google_service_account.default.email 77 oauth_scopes = [ 78 "https://www.googleapis.com/auth/cloud-platform" 79 ] 80 } 81 } 82 `, 83 } 84 85 var terraformEnableMasterNetworksLinks = []string{ 86 `https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#`, 87 } 88 89 var terraformEnableMasterNetworksRemediationMarkdown = ``