0
0
GCPcloud~10 mins

Preemptible and Spot VMs in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify a preemptible VM instance in the configuration.

GCP
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"
  }
}
Drag options to blanks, or click blank then click option'
A1
Bfalse
C"yes"
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using string values like "yes" instead of boolean true.
Setting preemptible to false which disables preemptible behavior.
2fill in blank
medium

Complete the code to specify a Spot VM instance using the instance_termination_action property.

GCP
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"
  }
}
Drag options to blanks, or click blank then click option'
Apreemptible
Binstance_termination_action
Cspot
Dtermination_action
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'preemptible' property which is for preemptible VMs, not Spot VMs.
Using incorrect property names like 'spot' or 'termination_action'.
3fill in blank
hard

Fix the error in the scheduling block to correctly configure a Spot VM with automatic restart disabled.

GCP
scheduling {
  provisioning_model = "SPOT"
  [1] = false
}
Drag options to blanks, or click blank then click option'
Aauto_restart
Brestart_auto
Cautomatic_restart
Drestart_automatically
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'auto_restart' which is not recognized.
Using 'restart_automatically' which is invalid.
4fill in blank
hard

Fill both blanks to configure a Spot VM with termination action set to terminate and no automatic restart.

GCP
scheduling {
  provisioning_model = "SPOT"
  [1] = "TERMINATE"
  [2] = false
}
Drag options to blanks, or click blank then click option'
Ainstance_termination_action
Bpreemptible
Cautomatic_restart
Drestart_policy
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 'preemptible' with Spot VM properties.
Using 'restart_policy' which is not valid here.
5fill in blank
hard

Fill all three blanks to create a preemptible VM with automatic restart disabled and a custom machine type.

GCP
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"
  }
}
Drag options to blanks, or click blank then click option'
A"custom-4-8192"
Btrue
Cfalse
D"e2-medium"
Attempts:
3 left
💡 Hint
Common Mistakes
Using default machine types instead of custom strings.
Setting preemptible to false which disables preemptible behavior.
Setting automatic_restart to true which enables restart.