无法从同一 VPC 内的 Lambda 连接到 Elasticache 无服务器内存缓存

问题描述 投票:0回答:1

我正在尝试为 Lambda 实施 AWS Elasticache 无服务器内存缓存。我已成功在跨越两个私有子网的 VPC 内配置无服务器 Elasticache。我也为 VPC 启用了

dns_hostnames
。我已使用相同的 2 个私有子网在同一 VPC 内成功部署 lambda。我已附加安全组,允许
11211
TCP 和
11212
TCP 入站流量发送到我的 Elasticache。我正在 lambda 中使用
memcache-plus
NPM 模块来连接到 Elasticache 服务器。我什至在 lambda 上附加了
elasticache:*
IAM 权限。问题是,每当我调用 lambda 时,它都会在这一步失败:

const MemcachePlus = require('memcache-plus');
const client = new MemcachePlus(process.env.ELASTICACHE_ENDPOINT);

为了成功连接到 Elasticache,我缺少什么?

尝试调用 lambda,将

MemcachePlus
类移动到 lambda 处理程序内部和外部。

aws-lambda terraform memcached amazon-vpc amazon-elasticache
1个回答
0
投票

根本原因可能与安全组设置或 VPC 配置不允许您的 Lambda 函数与 ElastiCache Serverless Memcached 建立连接有关。仔细检查附加到 Lambda 的安全组,确保其允许端口 11211 和 11212 上的 ElastiCache 出站流量,并验证子网和路由配置以确保可以进行内部 VPC 通信。

© www.soinside.com 2019 - 2024. All rights reserved.