如何将 VPC 内的 AWS Lambda 函数连接到 DynamoDB 等 public 资源?
How to connect AWS Lambda function inside a VPC to public resources like DynamoDB?
我正在尝试为 ElasticCache 启用我的 VPC lambda 函数以访问 DynamoDB。我知道为此,我需要设置一个 NAT 网关。但是,我无法使其工作。我的私有子网在 172.31.. 范围内。
这些是我正在执行的步骤:
- Create a public subnet with ip range in 10.0.0.0.
- Create a public VPC in the same IP range mentioned above.
- Create a public Internet gateway in the public VPC.
- Create a public route table, which is not the main route table and attach the public subnet to it. Then, add a route for 0.0.0.0/0 to the public Internet gateway created above.
- Create a NAT gateway in the public subnet. This NAT gets an Elastic IP and a Private IP in 10...* range.
现在我有 3 条路由 table,其中两条用于我的 public 子网 (10.0.0.0),一条用于我的私有子网 (172.31.0.0),它是我的私有 VPC 的一部分。
我的私有路由 table 有一个路由到 0.0.0.0/0 到我的私有 Internet 网关。
我想我需要更改此路由以指向我的 public NAT 网关,但是我无法这样做,因为我猜我的 NAT 的私有 IP 位于 10.0.0.0 范围内。我现在对如何进行感到困惑。我尝试在私有子网中创建一个 NAT 网关并将路由转发给它,但它也不起作用。我错过了什么?
愚蠢,但您是否有可能混淆默认 VPC (172.31...) 和您创建的 VPC (10.0...)。因此,如果您看到默认 VPC 的路由 table,它实际上是针对默认子网的,顺便说一下,它是 public!
我犯的错误是创建了两个 VPC,一个用于私有子网,另一个用于 public。除非启用对等互连,否则 AWS VPC 无法相互通信。
私有和 public 子网的概念对于具有网络背景的人来说起初是模棱两可的。它实际上意味着逻辑子网,它将具有可从 Internet 访问的资源(如 Web 服务器)和本地资源(如数据库服务器)(应受到 Internet 保护)。
我正在尝试为 ElasticCache 启用我的 VPC lambda 函数以访问 DynamoDB。我知道为此,我需要设置一个 NAT 网关。但是,我无法使其工作。我的私有子网在 172.31.. 范围内。
这些是我正在执行的步骤:
- Create a public subnet with ip range in 10.0.0.0.
- Create a public VPC in the same IP range mentioned above.
- Create a public Internet gateway in the public VPC.
- Create a public route table, which is not the main route table and attach the public subnet to it. Then, add a route for 0.0.0.0/0 to the public Internet gateway created above.
- Create a NAT gateway in the public subnet. This NAT gets an Elastic IP and a Private IP in 10...* range.
现在我有 3 条路由 table,其中两条用于我的 public 子网 (10.0.0.0),一条用于我的私有子网 (172.31.0.0),它是我的私有 VPC 的一部分。
我的私有路由 table 有一个路由到 0.0.0.0/0 到我的私有 Internet 网关。
我想我需要更改此路由以指向我的 public NAT 网关,但是我无法这样做,因为我猜我的 NAT 的私有 IP 位于 10.0.0.0 范围内。我现在对如何进行感到困惑。我尝试在私有子网中创建一个 NAT 网关并将路由转发给它,但它也不起作用。我错过了什么?
愚蠢,但您是否有可能混淆默认 VPC (172.31...) 和您创建的 VPC (10.0...)。因此,如果您看到默认 VPC 的路由 table,它实际上是针对默认子网的,顺便说一下,它是 public!
我犯的错误是创建了两个 VPC,一个用于私有子网,另一个用于 public。除非启用对等互连,否则 AWS VPC 无法相互通信。
私有和 public 子网的概念对于具有网络背景的人来说起初是模棱两可的。它实际上意味着逻辑子网,它将具有可从 Internet 访问的资源(如 Web 服务器)和本地资源(如数据库服务器)(应受到 Internet 保护)。