A team uses Terraform to create a VPC as shown. They now need to add a Compute Engine instance in the subnet. Which of the following correctly references the subnet?
self_link provides the full URL needed.
Why this answer
Option B is correct because when adding a Compute Engine instance to a subnet in Terraform, you must use the `subnetwork` argument (not `network`) and reference the subnet's `self_link` attribute. The `google_compute_subnetwork` resource's `self_link` provides the full URI required by the instance resource to attach to the correct subnet within the VPC.
Exam trap
Google Cloud often tests the distinction between `network` and `subnetwork` arguments, and the trap here is that candidates confuse the subnet's `name` attribute with its `self_link`, or mistakenly think the `network` argument can accept a subnet reference.
How to eliminate wrong answers
Option A is wrong because it sets `network = google_compute_subnetwork.subnet.self_link`, but the `network` argument expects a VPC network resource (e.g., `google_compute_network.vpc.self_link`), not a subnet self_link; this would cause a configuration error. Option C is wrong because `subnetwork = google_compute_subnetwork.subnet.name` uses only the subnet name, but the instance resource requires the full self_link URI to uniquely identify the subnet across projects or regions. Option D is wrong because it sets `network = google_compute_network.vpc.name` (which is a string name, not a self_link) and `subnetwork = google_compute_network.vpc.self_link` (which is a VPC self_link, not a subnet self_link); both arguments are incorrectly assigned, leading to a mismatch.