Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to Ensure Google Cloud Function Executes from a Specific Country (e.g., France or UK)?

 

Hi everyone,

I'm facing an issue with my Google Cloud Functions and would really appreciate some guidance.

  1. I'm currently using GCP's trial/free tier.
  2. I have a Cloud Function that is triggered by an unauthenticated HTTP request. The function calls <URL removed by staff>to check the IP address being used for its execution.
  3. The function then returns the country where it is executed from (i.e., the server's location, not the caller's location).

The Problem:

No matter which region I select for the function deployment (even when I select a region like Europe or specifically France), the function always seems to execute from the US. For instance, when I check the public IP, it resolves to a US-based server.

What I Need:

I want to ensure that my Cloud Function executes from a specific country, such as France or the UK, and that the IP reflects this location.

My Questions:

  1. Why is my function consistently executing from the US, even when I select a different region during deployment?
  2. How can I guarantee that my function executes from a specific region, like France or the UK, using only the free tier if possible?
  3. Is there a way to enforce this without resorting to a VPC and Cloud NAT (since this setup might incur extra costs)?
  4. Could this issue be related to me using a trial account, and would upgrading help?

Extra Info:

I know that using a VPC with Cloud NAT and static IP could work, but I'm looking for the simplest solution that would still allow me to control the region from which the function executes.

Thank you in advance for your help!

0 2 160
2 REPLIES 2

Even if you deploy your function in a specific region, the outbound IP might still appear as US-based because Google Cloud might route outbound traffic through US-based IPs for network optimization. To ensure your function executes from a specific region, double-check that you're selecting the correct region during deployment. However, note that the outbound IP might not always reflect the region due to the reasons mentioned above. The free tier might have limitations that affect how IPs are assigned, and while upgrading might give you more control, it doesn't guarantee regional IPs without additional configurations. Unfortunately, without using a VPC and Cloud NAT, controlling the outbound IP is challenging, as these services allow you to specify a static IP but can incur costs. Trial account might limit some advanced configurations. You can deploy functions in specific regions, but controlling the outbound IP without additional services like VPC and Cloud NAT is difficult. If regional IPs are crucial, consider upgrading and using these services (while, of course, keeping track of costs.

thank you very much for your reply.Can you please tell me the steps that I have to follow to make sure the outbound traffic is from a certain region ? (even if it includes vpc & nat, since they are necessary and I have no other choice