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.
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.
Cloud Functions do not have a public IP address assigned to the function.
Cloud Function egress traffic is routed to a proxy which then forwards the traffic to the public Internet. The only method to determine the current public IP address is to call a public endpoint which returns the public IP address of the frontend to Cloud Functions.
Here is an example endpoint: https://api64.ipify.org/?format=json
If you want to have a outbound static IP with Cloud Functions, you can achieve this by configuration. 3 important steps
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!