Complete the code to specify a preemptible VM instance in the configuration.
resource "google_compute_instance" "vm_instance" { name = "preemptible-vm" machine_type = "e2-medium" zone = "us-central1-a" scheduling { preemptible = [1] } boot_disk { initialize_params { image = "debian-cloud/debian-11" } } network_interface { network = "default" } }
Setting preemptible = true marks the VM as preemptible, allowing Google Cloud to shut it down at any time to save costs.
Complete the code to specify a Spot VM instance using the instance_termination_action property.
resource "google_compute_instance" "spot_vm" { name = "spot-vm" machine_type = "e2-medium" zone = "us-central1-a" scheduling { provisioning_model = "SPOT" [1] = "TERMINATE" } boot_disk { initialize_params { image = "debian-cloud/debian-11" } } network_interface { network = "default" } }
The property instance_termination_action set to TERMINATE is used to configure Spot VMs to terminate when Google Cloud reclaims the instance.
Fix the error in the scheduling block to correctly configure a Spot VM with automatic restart disabled.
scheduling {
provisioning_model = "SPOT"
[1] = false
}The correct property to disable automatic restart is automatic_restart. Using other variants will cause errors.
Fill both blanks to configure a Spot VM with termination action set to terminate and no automatic restart.
scheduling {
provisioning_model = "SPOT"
[1] = "TERMINATE"
[2] = false
}Spot VMs use instance_termination_action to specify termination behavior and automatic_restart to control restart on failure.
Fill all three blanks to create a preemptible VM with automatic restart disabled and a custom machine type.
resource "google_compute_instance" "custom_vm" { name = "custom-preemptible-vm" machine_type = [1] zone = "us-central1-a" scheduling { preemptible = [2] automatic_restart = [3] } boot_disk { initialize_params { image = "debian-cloud/debian-11" } } network_interface { network = "default" } }
The machine type is set to a custom type string. Preemptible is enabled with true, and automatic restart is disabled with false.