A DevOps engineer needs to update an existing firewall rule named allow-internal-web in a custom Virtual Private Cloud (VPC) network. The rule currently filters traffic using the network tag legacy-web-backend. The team is migrating to identity-based security controls and requires the firewall rule to target instances using the service account [email protected] instead, while removing the existing network tag filter. Which gcloud command should the engineer execute to complete this operational change?
- gcloud compute firewall-rules update allow-internal-web --target-service-accounts=web-runner@prod-app.iam.gserviceaccount.com --remove-target-tags=legacy-web-backendAnswer
- Bgcloud compute firewall-rules update allow-internal-web [email protected]
- Cgcloud compute firewall-rules create allow-internal-web --target-service-accounts=web-runner@prod-app.iam.gserviceaccount.com --force
- Dgcloud compute firewall-rules update allow-internal-web --priority=65535 --direction=EGRESS
Answer
Execute the command gcloud compute firewall-rules update allow-internal-web --target-service-accounts=web-runner@prod-app.iam.gserviceaccount.com --remove-target-tags=legacy-web-backend.
The correct command uses the `gcloud compute firewall-rules update` subcommand along with `--target-service-accounts` to set the service account identity and `--remove-target-tags` to clear the previous network tag target.
Step-by-Step Solution
Key Concept
Managing VPC Firewall Rules with gcloud CLI