1

Here on console, I am able to see a total of 7 resources. Which does not match with the result got from the API call. With API calls I am getting 75 resources:

External IP addresses

GCP Doc link https://cloud.google.com/compute/docs/reference/rest/v1/addresses/list

Method GET: https://compute.googleapis.com/compute/v1/projects/{project}/regions/{region}/addresses

Here for us-east1 UI console shows 1 entry and API gives 4 records.

EDIT

For region us-east1 there are 4 records:

API response for region

Serhii Rohoza
  • 4,287
  • 2
  • 16
  • 29
  • Could you provide output of the API request? I've tried on my test project and it works good for me. – Serhii Rohoza Mar 26 '21 at 09:37
  • Yes @SerhiiRohoza i have added response – user3269980 Mar 26 '21 at 11:36
  • Thanks! On the screenshot you provided I can see EXTERNAL IPs, but at the API I can see INTERNAL IPs. So, maybe it's a reason for the difference in results. – Serhii Rohoza Mar 26 '21 at 11:47
  • Does it mean the APIs must be different. As per Official documentation result on the GCP console should match with, result from the API call. – user3269980 Mar 26 '21 at 12:08
  • Just set the proper `items[].addressType` as it's described at the [documentation](https://cloud.google.com/compute/docs/reference/rest/v1/addresses/list`). – Serhii Rohoza Mar 26 '21 at 12:44
  • Are you counting the external or internal IP? I'm lost here! – guillaume blaquiere Mar 26 '21 at 13:00
  • Have you solved your issue with setting proper `items[].addressType`? – Serhii Rohoza Mar 29 '21 at 07:57
  • Out of 75 from API calls, only 2 are shown on the console, which is of type `static`. Here for asia-east1 1 of type `static` matched in UI and API and 4 are of `Ephemeral` does not match up in API. – user3269980 Mar 30 '21 at 06:46
  • @SerhiiRohoza No, `items[].addressType` This helps to get a specific type(INTERNAL, EXTERNAL), what I notice is we do not get `Ephemeral` type via region-specific APIs. – user3269980 Mar 30 '21 at 06:52
  • Accordingly to the [documentation](https://cloud.google.com/compute/docs/reference/rest/v1/addresses/list) for this API request: `items[].address` `string` "The **static** IP address represented by this resource". So, it's expected that you didn't get any `Ephemeral`. – Serhii Rohoza Mar 30 '21 at 07:07
  • Yes, noticed @SerhiiRohoza Thank you for your time. – user3269980 Mar 30 '21 at 07:44
  • Thank you! I posted an answer (as a summary of research here), please accept/upvote if my assistance was helpful. – Serhii Rohoza Mar 30 '21 at 08:27

1 Answers1

0

As it was discussed at the comment section, you see mismatch between Cloud Console (image 1) and API request (image2) because UI shows you EXTERNAL IP and API shows INTERNAL IP.

To solve this issue you should follow API documentation Method: addresses.list and set required items[].addressType:

The type of address to reserve, either INTERNAL or EXTERNAL. If unspecified, defaults to EXTERNAL.

Furthermore, you can see EPHEMERAL IP via Cloud Console UI, but accordingly to the API documentation items[].address:

The static IP address represented by this resource.

Serhii Rohoza
  • 4,287
  • 2
  • 16
  • 29