'How can I see which IP address Google Cloud Function instance use?

I want to see the IP address of my google function instance. I've tried to look request object's headers but couldn't find anything useful. Is there any way to find it?

I am using python SDK but I don't think this is language dependent.



Solution 1:[1]

If you want to have a outbound static IP with Cloud Functions, you can achieve this by configuration. 3 important steps

Solution 2:[2]

Just if someone needs this.

After doing the steps described by guillaume and exploring the link that also John suggested, I was able to get my cloud function's IP with the following python code:

from requests import get

ip = get('https://api.ipify.org').text
print(f'My public IP address is: {ip}')

In my case, I was looking to see if my cloud function had the same IP address as my NAT gateway since I need to put the IP in a whitelist and this helped me a lot!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 guillaume blaquiere
Solution 2 Osain