01 Run projects list command (Windows/macOS/Linux) with custom query filters to list the IDs of the Google Cloud Platform (GCP) projects currently available in your Google Cloud account:
gcloud projects list
--format="table(projectId)"
02 The command output should return the requested GCP project identifiers (IDs):
PROJECT_ID
cc-main-project-123123
cc-data-project-112233
03 Run compute networks list command (Windows/macOS/Linux) with the ID of the GCP project that you want to examine as the identifier parameter and custom query filters to describe the name of each VPC network created within the selected project:
gcloud compute networks list
--project cc-main-project-123123
--format="table(name)"
04 The command output should return the name(s) of the VPC network(s) created for the specified project:
NAME
cc-web-stack-network
cc-project5-vpc-network
05 Run compute firewall-rules list command (Windows/macOS/Linux) with the name of the VPC network that you want to examine as the identifier parameter and custom filtering to list all the network firewall rules (and their status) created for the selected VPC:
gcloud compute firewall-rules list
--filter network=cc-web-stack-network
--sort-by priority
--format=table"(name,disabled)"
06 The command output should return the name and the state of each firewall rule available for the selected VPC. The firewall rules with DISABLED set to False are active rules:
NAME: web-stack-allow-ssh
DISABLED: False
NAME: web-stack-allow-http
DISABLED: False
NAME: web-stack-allow-https
DISABLED: False
07 Run compute firewall-rules describe command (Windows/macOS/Linux) with the name of the active firewall rule that you want to examine as the identifier parameter, to describe the target tags defined for the selected rule:
gcloud compute firewall-rules describe web-stack-allow-ssh
--format=table"(targetTags)"
08 The command output should return the requested tagging information:
TARGET_TAGS: ['ssh-access']
09 Run compute instances list command (Windows/macOS/Linux) with custom query filters to list the name and the network (target) tag available for each Compute Engine instance provisioned for the selected GCP project:
gcloud compute instances list
--project cc-main-project-123123
--format="table(name,tags.items)"
10 The command output should return the name and the network tag(s) available for each provisioned instance:
NAME: cc-prod-vm-instance
ITEMS: ['http-server', 'https-server']
NAME: cc-backend-instance
ITEMS: ['backend-server']
NAME: cc-windows-instance
ITEMS: ['win-server', 'backend-server']
If none of the Compute Engine instances listed by the
compute instances list command have the network (target) tag identified in step 8, the selected network firewall rule is not associated with a compute resource, therefore, the firewall rule is considered unused and can be disabled or removed from your Google Cloud account.
11 Repeat steps no. 7 - 10 for each firewall rule defined for the selected GCP project.
12 Repeat steps no. 3 – 11 for each GCP project deployed in your Google Cloud account.