01 Run projects list command (Windows/macOS/Linux) using custom query filters to list the IDs of all the Google Cloud Platform (GCP) projects available in your cloud account:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
gcloud projects list
--format="table(projectId)"
02 The command output should return the requested GCP project IDs:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
PROJECT_ID
cc-web-stack-project-123123
cc-legacy-app-project-112233
03 Run compute instances list command (Windows/macOS/Linux) using the ID of the GCP project that you want to examine as identifier parameter and custom query filters to describe the name and zone for each VM instance launched for the selected project:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
gcloud compute instances list
--project cc-web-stack-project-123123
--format="table(name,zone)"
04 The command output should return the name(s) of the instance(s) within the selected GCP project:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
NAME ZONE
cc-production-instance us-central1-a
cc-staging-vm-instance us-central1-a
05 Run compute instances describe command (Windows/macOS/Linux) using the name and the zone of the instance that you want to examine as identifier parameter and custom filtering to describe the access configuration for the network interface(s) attached to the selected instance:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
gcloud compute instances describe cc-production-instance
--zone us-central1-a
--format="json(networkInterfaces[].accessConfigs)"
06 The command output should return the requested configuration information:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
{
"networkInterfaces": [
{
"accessConfigs": [
{
"kind": "compute#accessConfig",
"name": "External NAT"
,
"natIP": "xxx.xxx.xxx.xxx",
"networkTier": "PREMIUM",
"type": "ONE_TO_ONE_NAT"
}
]
}
]
}
If the
compute instances describe command output returns one or more
accessConfigs objects with an
natIP property, as shown in the example above, the selected Google Compute Engine instance is configured to use a public/external IP address. For Google Cloud instances that are stopped and configured to have an ephemeral public IP address, the
accessConfigs object exists but the
natIP property is not present.
07 Repeat step no. 5 and 6 for each virtual machine instance created within the selected project.
08 Repeat steps no. 3 – 7 for each GCP project deployed in your Google Cloud account.