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

Access compute engine from cloud run service

Hi,

I have a Django Rest API running in Cloud Run.

For the time being, I also have a compute engine instance that has Redis, Celery beat, and Celery workers set up in it. (willing to architect a better solution for this later)

I tried accessing Redis in this compute instance for caching purposes from the serverless cloud run, but I got a connection timeout because the firewall was blocking the access.

Do I need to set up a VPC Access Connector for this (seems like a bit of an overkill for my use case)? I am not familiar with VPC set up nor with access connectors, and I simply allowed all IPs to access my Redis instance for now which is obviously not very secure.

I wouldn't like to create a Memorystore instance right now because of the high cost.

Any guidance/links to educational material or documentation are appreciated. Thanks!

Solved Solved
0 5 1,222
1 ACCEPTED SOLUTION

Hi meric,

Yes, a VPC Access Connector is the correct tool for this use case. You can see more here: Cloud Run: Connecting to a VPC network.

View solution in original post

5 REPLIES 5

Hi meric,

Yes, a VPC Access Connector is the correct tool for this use case. You can see more here: Cloud Run: Connecting to a VPC network.

Apparently I need a VPC Access Connector even if I am connecting to a memorystore instance so I'll either way set that up. Thanks for the response 🙌

So I did create a memorystore instance as well as a VPC Access connector but it still doesn't work. What am I doing wrong 🤔 @cloudpaul appreciate if you can take a look 🙏 Should I have maybe entered something else for the subnet / IP address range for the connector?

 

cloud run config (Region: europe-west1)

Screenshot 2021-11-25 at 20.15.35.png

 

Connector:

Screenshot 2021-11-25 at 20.16.31.png

Memorystore config:

Screenshot 2021-11-25 at 20.17.29.png

By "doesn't work" I mean:

Screenshot 2021-11-25 at 20.40.17.png

Hi meric,

Dou you have an ingress Firewall Rule allowing traffic from Serverless VPC Connector IP range in default VPC?.