I am trying the option for spot in this link: google_container_cluster | Resources | hashicorp/google | Terraform Registry
My terraform file:
I tried this template:
provider "google" {
credentials = file("service-account.json")
project = "project1"
region = "us-central1"
zone = "us-central1-c"
}
resource "google_service_account" "default" {
account_id = "k8stestaccount"
display_name = "k8s-uday"
}
resource "google_container_cluster" "primary" {
name = "my-gke-cluster"
location = "us-central1"
# We can't create a cluster with no node pool defined, but we want to only use
# separately managed node pools. So we create the smallest possible default
# node pool and immediately delete it.
remove_default_node_pool = true
initial_node_count = 1
}
resource "google_container_node_pool" "primary_preemptible_nodes" {
name = "my-node-pool"
location = "us-central1"
cluster = google_container_cluster.primary.name
node_count = 1
node_config {
#preemptible = true
spot = true
machine_type = "e2-medium"
# Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles.
service_account = google_service_account.default.email
oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform"
]
}
}
I am getting error as for terraform plan:
Error: Unsupported argument
│
│ on main.tf line 32, in resource "google_container_node_pool" "primary_preemptible_nodes":
│ 32: spot = true
│
│ An argument named "spot" is not expected here.
Even with google-beta provider used, getting same error.
Google Provider Versions | Guides | hashicorp/google | Terraform Registry