0
0
GCPcloud~10 mins

Why IaC matters in GCP - Test Your Understanding

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

Complete the code to define infrastructure as code using Terraform.

GCP
resource "google_compute_instance" "vm_instance" {
  name         = "example-instance"
  machine_type = "[1]"
  zone         = "us-central1-a"
}
Drag options to blanks, or click blank then click option'
An1-standard-1
Bstandard-1
Cmicro-1
Dsmall-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using an invalid machine type name causes deployment errors.
Leaving the machine_type blank will fail the resource creation.
2fill in blank
medium

Complete the code to specify the network interface for the VM instance.

GCP
resource "google_compute_instance" "vm_instance" {
  network_interface {
    network = "[1]"
  }
}
Drag options to blanks, or click blank then click option'
Adefault
Bprimary
Cmain-network
Ddefault-network
Attempts:
3 left
💡 Hint
Common Mistakes
Using a network name that does not exist causes deployment failure.
Adding spaces or hyphens incorrectly in the network name.
3fill in blank
hard

Fix the error in the Terraform code to correctly set the boot disk image.

GCP
boot_disk {
  initialize_params {
    image = "[1]"
  }
}
Drag options to blanks, or click blank then click option'
Aubuntu-20-04
Bubuntu-1804-lts
Cubuntu-latest
Dprojects/ubuntu-os-cloud/global/images/ubuntu-1804-bionic-v20210429
Attempts:
3 left
💡 Hint
Common Mistakes
Using short or incomplete image names causes Terraform to fail.
Misspelling the image path leads to errors.
4fill in blank
hard

Fill both blanks to create a firewall rule allowing HTTP traffic.

GCP
resource "google_compute_firewall" "http_firewall" {
  name    = "allow-http"
  network = "[1]"
  allow {
    protocol = "[2]"
    ports    = ["80"]
  }
}
Drag options to blanks, or click blank then click option'
Adefault
Bhttps
Ctcp
Dmain
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong network name causes the firewall to not apply.
Using 'https' instead of 'tcp' for the protocol is incorrect.
5fill in blank
hard

Fill all three blanks to output the VM instance's external IP address.

GCP
output "instance_ip" {
  value = google_compute_instance.[1].network_interface[[2]].access_config[[3]].nat_ip
}
Drag options to blanks, or click blank then click option'
Avm_instance
B0
Dinstance
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect resource names causes output errors.
Using wrong indexes leads to missing IP addresses.