将 Lambda 连接到不同可用区中的 Redshift [英] Connect Lambda to Redshift in Different Availability Zones

查看:24
本文介绍了将 Lambda 连接到不同可用区中的 Redshift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的 Redshift 集群位于 A 区.

Our Redshift cluster resides in Zone A.

当我们的 Lambda 函数使用区域 A 子网时,它可以连接到 Redshift.

When our Lambda function uses a Zone A subnet, it can connect to Redshift.

当我们的 Lambda 函数使用区域 A 以外的子网时,它会超时.

When our Lambda function uses a subnet other than Zone A, it times out.

我们不需要从 0.0.0.0/0 开始在端口 5439 上连接 Redshift 的解决方法.

The work around, where we ALLOW connections for Redshift on port 5439 from 0.0.0.0/0, is not desired.

  • 我们在同一 VPC 中拥有 Lambda 函数和 Redshift 集群.
  • Lambda 函数有 4 个专用子网(每个区域一个)
  • Redshift 每个区域也有 4 个专用子网
  • Lambda 函数有自己的安全组 (SG)
  • Redshift 集群也有自己的 SG.
  • Redshift SG 允许来自 Lambda SG 和 Admin SG 的端口 5439
  • 增强型 VPC 路由 已启用
  • 集群子网组包括所有 4 个 Redshift 子网(每个区域一个)
  • 在 Redshift SG 上允许来自 0.0.0.0/0 的端口 5439 时没有问题
  • 当我们禁用 0.0.0.0/0 规则时,REJECT 的流日志从 A 区到 A 区工作正常,但不能从其他区到 A 区.
  • 所有 Lambda 子网都使用存在于区域 A 中的 NAT
  • 所有 Redshift 子网都使用存在于
  • 中的 IGW
  • 所有网络 ACL 当前允许所有(默认)
  • We have our Lambda functions and Redshift cluster in the same VPC.
  • Lambda functions have 4 dedicated subnets (one per zone)
  • Redshift has 4 dedicated subnets per zone as well
  • Lambda functions have their own security group (SG)
  • The Redshift cluster has it's own SG as well.
  • Redshift SG ALLOWs port 5439 from Lambda SG and Admin SG
  • Enhanced VPC Routing is enabled
  • Cluster Subnet Groups include all 4 Redshift subnets (one per zone)
  • No issues when allowing port 5439 from 0.0.0.0/0 on Redshift SG
  • Flow logs for REJECT work fine from Zone A to Zone A, but not from other zones to Zone A when we disable 0.0.0.0/0 rule.
  • All Lambda subnets use a NAT that exists in Zone A
  • All Redshift subnets use an IGW that exists in
  • All Network ACLs currently allow all (default)

推荐答案

我遇到了类似的情况.将 NAT 网关的弹性 ip 添加到 Redshift 安全组的入站规则中,端口 5439 为我修复了它.

I was stuck in a similar situation. Adding the NAT gateway's elastic ip to the inbound rule of Redshift's security group for port 5439 fixed it for me.

步骤:

  • 使用 NAT 网关 (subnet-abc) 检查 lambda 的私有子网
  • 转到 VPC 控制台 > 子网 > 子网 abc > 路由表
  • 在路由表路由中,可以找到使用的 NAT 网关 (nat-abcdefg)
  • 转至 VPC 控制台 > NAT 网关 > nat-abcdefg.获取此 NAT 网关使用的 elastic-ip.(xx.yy.zz.pqr)
  • 在 redshift 的安全组中为此弹性 IP 添加入站规则(端口 = 5439 CIDR xx.yy.zz.pqr/32)

沃拉!Lambda 连接到红移.

Volla! Lambda connects to redshift.

不过,在执行此操作之前,应在与 redshift 相同的 VPC 中配置 lambda,并按照 OP 的建议使用适当的私有子网(配置为使用 NAT 网关).

Though, before doing this, lambda should be configured in the same VPC as redshift and using the appropriate private subnet (configured to use NAT gateway) as OP suggested.

这篇关于将 Lambda 连接到不同可用区中的 Redshift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆