A cloud engineer needs to deploy a custom Virtual Private Cloud (VPC) infrastructure in Google Cloud to host secure internal applications. The requirements specify creating a VPC network without automatic subnet creation, provisioning a regional subnet, launching a Compute Engine VM with a specific network tag in that subnet, and enforcing an ingress firewall rule that allows SSH traffic (TCP port 22) exclusively to instances carrying that network tag. In what order should the engineer execute the following `gcloud` CLI commands to ensure all resource dependencies are satisfied without errors?
- 1Execute `gcloud compute networks create enterprise-vpc --subnet-mode=custom` to create the VPC network container.
- 2Execute `gcloud compute networks subnets create prod-subnet-us-central1 --network=enterprise-vpc --region=us-central1 --range=10.10.0.0/24` to provision the regional custom subnet.
- 3Execute `gcloud compute instances create app-vm-1 --zone=us-central1-a --subnet=prod-subnet-us-central1 --tags=bastion-ssh-target` to launch the virtual machine with the designated network tag.
- 4Execute `gcloud compute firewall-rules create allow-bastion-ssh --network=enterprise-vpc --direction=INGRESS --priority=1000 --action=ALLOW --rules=tcp:22 --target-tags=bastion-ssh-target` to deploy the target-filtered firewall rule.
Cevap
The correct operational sequence begins with provisioning the parent VPC network in custom subnet mode (`gcloud compute networks create --subnet-mode=custom`), followed by creating the regional custom subnet inside that network (`gcloud compute networks subnets create`), then launching the Compute Engine VM instance attached to the subnet with the designated network tag (`gcloud compute instances create --tags`), and finally creating the ingress firewall rule configured with matching target tags on the VPC network (`gcloud compute firewall-rules create --target-tags`).
Resource creation in Google Cloud networking strictly follows a hierarchical dependency structure: Network → Subnet → Compute Instance with Tags → Firewall Rule targeting Tags. Creating the VPC network with `--subnet-mode=custom` establishes the network container. Next, explicit creation of the regional subnet defines the IP address space. The VM instance is then provisioned into that subnet and assigned network tags. Finally, the firewall rule targeting those network tags is created on the network.
Adım Adım Çözüm
Anahtar Kavram
GCP VPC Resource Dependency Hierarchy and Deployment Sequencing
Tahmini Süre:2m 30s