user2459291
user2459291

Reputation:

Accessing Remote Region MemoryDB from VPC

I have a Lambda Function running in EU-WEST-2. The function is running in a VPC and it is attempting to access a MemoryDB cluster running in US-EAST-2. However, it fails to connect.

The Lambda Function is running in a subnet that can route from the VPC in EU-WEST-2 to the VPC in US-EAST-2 (using VPC peering).

I have run a VM in the same subnet in EU-WEST-2, installed Redis-CLI and it is able to connect.

Running the "Reachability Analyzer" from the Lambda Interface to the MemoryDB Interface, shows no issues.

Starting a MemoryDB Cluster in EU-WEST-2 allows the same Lambda function to connect.

Therefore, having checked all (or maybe not?) possible KNOWN scenarios, I'm starting to wonder if this scenario isn't allowed/blocked somehow?

Is this a valid/supported scenario?


const Redis = require('ioredis');

const redisClient = new Redis.Cluster([{host:process.env.redisClusterURI,port:6379}],{dnsLookup: (address, callback) => callback(null, address), redisOptions: {tls: true},slotsRefreshTimeout:5000,slotsRefreshInterval:300000});

redisClient.defineCommand("getSensitive", {numberOfKeys:1,lua:"local sum = 0; local matches = redis.call('KEYS', KEYS[1]); for _,key in ipairs(matches) do local val = redis.call('GET', key) sum = sum + tonumber(val) end;return tostring(sum);"});

const testRedis=async()=>{try{var t = await redisClient.ping();}catch(e){await log(e,true)};if(t=="PONG"){return true;}else{return false;};};

const log=async(o,e)=>{"1"===process.env.enableLogging&&(e?console.error(o):console.log(o))};

exports.streamhandler = async () => {

    var redisTestSuccess = await testRedis();
    
    if(redisTestSuccess){
        await log("Redis connected.");
        try{var sensitiveData = await redisClient.getSensitive("**sensitive**")}catch(e){await log(e,false)};
        //Do things with the response
    }else{
        await log("Redis not connected.");
    };
};

Upvotes: 1

Views: 171

Answers (0)

Related Questions