AWS 安全组:入站规则的来源是否与安全组名称相同?

AWS Security group : source of inbound rule same as security group name?

我有一个 ec2 实例,它是 运行 一个网站并关联了 ALB。

normally as a practice inside the ec2 instance security group, alb security group is referenced, but here the client has a configuration in such a way that inside ec2 instance the source is name of the security group itself.

名称为

的ec2实例的安全组
sg-0bc7e4b8b0fc62ec7 - default

根据我对aws安全组的理解,在的入站规则下,我们可以提及IP地址,或CIDR块或reference another security group

但这对于入站规则意味着什么,其中允许所有流量、所有端口但对于源 = sg-0bc7e4b8b0fc62ec7 / default.

I am confused with usage of the same name of the security group as source, what this rule will mean?

每个 VPC 都有一个 default security group (SG)。在此 SG 中,入站规则允许所有来自“自身”的传入流量。这意味着

When you specify a security group as the source for a rule, traffic is allowed from the network interfaces that are associated with the source security group for the specified protocol and port.

换句话说,如果你有两个使用默认VPC SG的实例,它们只能相互通信。任何一个实例都不允许其他入站流量。

使用 SG 作为源是一种很好的做法,如果经常在负载均衡器 (LB) 与其实例之间或实例与 RDS 数据库之间使用的话。在第一种情况下,实例仅允许来自 LB 的 SG 的传入流量,而在第二种情况下,db 实例仅允许来自实例的 SG 的传入连接。