在 EC2 实例的安全组中添加入站规则,以允许 EventBridge API Destination 对 EC2 私有 IP 的连接。具体步骤如下:
规则类型:自定义 TCP 规则 协议:TCP (6) 来源:EventBridge API Destination 的 IP (或指定 IP 网段) 端口范围:自定义,根据应用需要指定
示例:
{ "source": [ "aws.ec2" ], "detail-type": [ "EC2 Instance State-change Notification" ], "resources": [ "arn:aws:ec2:::instance/*" ], "detail": { "state": "stopped" }, "config": { "destinationConfig": { "httpEndpoint": "http://10.0.0.10:8080/events" } } }
在这个例子中,EventBridge API Destination 会将 EC2 实例状态更改通知发送到指定的 HTTP 端点。为了允许 EventBridge API Destination 访问 EC2 实例的私有 IP 10.0.0.10,需要在 EC2 实例安全组中添加一条入站规则,允许 TCP 连接到该 IP 的 8080 端口。具体规则设置如下:
规则类型:自定义 TCP 规则 协议:TCP (6) 来源:EventBridge API Destination 的 IP (或指定 IP 网段) 端口范围:8080
添加规则后,即可