创建仅对内部 VPC 实例和单个外部服务开放的 AWS EC2 安全组

Create AWS EC2 security group open only to internal VPC instances and a single external service

我有一个 Elastic Beanstalk 实例,它用作管理仪表板呈现 HTML 模板和从数据库提供的数据。这个和数据库在一个特定的 VPC 中。

在 VPC 中,我还有另一个单实例 Elastic Beanstalk 应用程序,它用作 Web 套接字客户端,将来自外部服务的数据保存到数据库中。这些是下图中的摄取提要。

Ingestion feeds 有 HTTP Rest 端点,我可以从 start/stop Ingestion feeds 的管理仪表板点击。

我遇到的问题是如何从 VPC 外部关闭 Ingestion Feed。我希望它仅从 Admin Dashboard Elastic Beanstalk 应用程序连接。

但我也希望他们能够通过网络套接字连接到外部服务。

这应该符合您的要求:

管理仪表板服务器:安全组 A

  • 入站规则允许在您的仪表板服务的任何端口上进行流量,可能是端口 80 and/or 443。
  • 默认出站规则

摄取源服务器:安全组 B

  • 没有入站规则(见下面的注释)
  • 默认出站规则

数据库服务器:安全组 C

  • 允许属于安全组 A 的实例访问的入站规则 数据库端口
  • 允许属于安全组 B 的实例访问数据库端口的入站规则
  • 默认出站规则

注:

来自the documentation

Security groups are stateful — if you send a request from your instance, the response traffic for that request is allowed to flow in regardless of inbound security group rules. Responses to allowed inbound traffic are allowed to flow out, regardless of outbound rules.

这应该允许您的 Ingestion Feeds 服务创建与外部服务的连接并在该连接上接收响应,而无需为 Ingestion Feeds 实例分配任何入站规则。