gpt4 book ai didi

amazon-web-services - AWS - 配置从 Beanstalk 应用程序对 EC2 实例的访问

转载 作者:行者123 更新时间:2023-12-02 01:34:33 24 4
gpt4 key购买 nike

因此,由于我不想详细说明的原因,我的数据库位于 eu-west-1 中的 EC2 实例上,并且我在 us-east-1 上创建了一个 beanstalk 应用程序。我希望我的应用程序能够在 MySQL 端口 (3306) 上与该 EC2 实例进行通信。

任何人都可以协助我如何设置它,我需要在 EC2 安全组上设置哪些入口规则?鉴于我将在 beanstalk 中拥有该应用程序的多个版本,IP 地址可能会定期更改(在环境重建后等)。

最佳答案

关于Security Group Rules的重要概念您可能会忽略的是,您不必单独指定 IP 地址作为流量源,而是经常会引用其他安全组:

The source can be an individual IP address (203.0.113.1), a range of addresses (e.g., 203.0.113.0/24), or an EC2 security group. The security group can be another group in your AWS account, a group in another AWS account, or the security group itself.

By specifying a security group as the source, you allow incoming traffic from all instances that belong to the source security group. [...] You might specify another security group in your account if you're creating a three-tier web service (see Creating a Three-Tier Web Service).

[emphasis mine]

因此,您只需添加 Beanstalk 应用实例安全组作为 MySQL 实例安全组内 TCP 端口 3306 的流量源。

<小时/>

更进一步

需要熟悉的另一个概念是,您可以将多个安全组分配给一个实例,从而启用(可能是动态的)最终防火墙的组合。

例如,针对大型架构的推荐做法建议为您的实例所具有的每个“角色”指定一个专用安全组(而不是像往常一样在一个安全组内累积多个规则),例如我们有“role-ssh”(TCP 端口 22)和“role-mysql”(TCP 端口 3306)等安全组,它们根据需要依次分配给 EC2 实例。您可以阅读有关此概念的更多信息,例如Security Groups - Most Underappreciated Feature of Amazon EC2 .

关于amazon-web-services - AWS - 配置从 Beanstalk 应用程序对 EC2 实例的访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8791452/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com