Summary
I'll show an example configuration of GCP Serverless VPC Access in this post. The scenario here will be a Cloud Function that needs to access Memorystore (GCP managed Redis). Memorystore is isolated in a VPC with a private range address - which is good as far as security is concerned. To access that VPC from Cloud Functions, a Serverless VPC connector needs to be built.
Architecture
Memorystore Configuration
Serverless VPC Configuration
Cloud Function Configuration
Cloud Function Redis Client Connection Code
const {createClient} = require('redis'); getClient() { const client = createClient({ socket: { host: process.env.REDIS_HOST }, password: process.env.REDIS_PASS }); client.on('error', (err) => { throw Error(`redis client error: ${err}`); }); return client; }
Copyright ©1993-2024 Joey E Whelan, All rights reserved.