Configurations to connect with a redis instance

Hi Team,

I want to access the redis instance running in the same google project via cloud function. For this I set egress flag to all however the cloud function requires an connector configuration. Is there a way I can connect with my redis instance without one. 

Error: ERROR: (gcloud.functions.deploy) Missing required argument [vpc-connector]: Flag `--vpc-connector` is required for setting `--egress-settings`.

 
Redis Config:
Authorized networkdefault {xyz-My Network for other services outside project}
Connection modePrivate service access
 
Can Please also share a specific example via which I can configure my vpc-connector setting if needed, thanks!!
0 2 276
2 REPLIES 2

Hi @ankit-pradhan,

Welcome to Google Cloud Community!

Connecting your Cloud Function to a Redis instance within the same project requires a VPC connector due to private access restrictions. You can choose between two options:

1. Configure a VPC Connector:

  • Create a VPC connector and specify its name during Cloud Function deployment using the --vpc-connector flag.
  • Keep egress settings as "all" as the connector directs traffic through the authorized VPC network.

2. Modify Redis Connection Mode (less secure):

  • Change connection mode to "Direct peering" in the Memorystore for Redis interface.
  • This grants access to all authorized networks in your project, bypassing the VPC connector.

Remember, security considerations favor using a VPC connector for controlled access.

Documentation Reference:

Connecting to a Redis instance from Cloud Functions:

VPC connector configuration:

Redis instance connection mode:

 

I took the same error, even send the flag:
`gcloud functions deploy hello_world --runtime python310 --vpc-connector <my-connector-name> --egress-settings private-ranges-only --ingress-settings internal-only --trigger-http

and the error persists: Flag `--vpc-connector` is required for setting `egress-settings`.