I tried to stop a GCP VM in terraform using desired_status = "TERMINATED" but I get the following error code:
Error: Unsupported argument
on main.tf line 24, in resource "google_compute_instance" "default": 24: desired_status = "TERMINATED"
An argument named "desired_status" is not expected here.
The full terraform code is:
terraform {
required_providers {
google = {
source = "hashicorp/google"
}
}
}
provider "google" {
version = "3.5.0"
credentials = file("cred.json")
project = "project-gcp-25625415"
region = "us-central1"
zone = "us-central1-c"
}
resource "google_compute_instance" "default"{
name = "terra2"
machine_type = "f1-micro"
zone = "us-central1-a"
desired_status = "TERMINATED"
boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
}
}
network_interface {
network = "default"
access_config {
// Ephemeral IP
}
}
}