我一直在寻找为什么我认为应该有效的东西,为什么不。这是一个细分
- 我在该安全组中有一个具有公共分配 IP 的堡垒,可启用所有出口流量。还有这个,有点问题:
FooSSHIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
IpProtocol: tcp
FromPort: 22
ToPort: 22
GroupId:
Fn::ImportValue: !Sub "${FooStackName}-AdminSecurityGroup"
SourceSecurityGroupId: !Ref BastionSecurityGroup
Description: Enables SSH to FooService
所以我试图允许来自的连接到达另一个名为froBastionSecurityGroup@22
的安全组。AdminSecurityGroup
FooStack
AdminSecurityGroup
可以在下面找到。显然是空的,但请耐心等待。关键是要有一个可以链接到某处以启用 SSH 访问的安全组。
AdminSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: >-
For FooService admin access.
Grants access to EC2 instances over SSH.
VpcId:
Fn::ImportValue: !Sub "${VpcStackName}-VPCId"
无论如何,上面的那个组后来链接到 SecurityGroup最终在AWS::EC2::LaunchTemplate
. 它的定义如下:
ServerSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Enable Client and Admin access
VpcId:
Fn::ImportValue: !Sub "${VpcStackName}-VPCId"
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: !Ref ClientPort
ToPort: !Ref ClientPort
SourceSecurityGroupId: !Ref ClientSecurityGroup
- IpProtocol: tcp
FromPort: 22
ToPort: 22
SourceSecurityGroupId: !Ref AdminSecurityGroup
正如你所看到的,也ClientSecurityGroup
有遵循相同的模式。
最后,问题是:
- 是否有意义?
- 为什么它不起作用?据我所知,拥有这样的安全组应该会导致通过 ENI 路由流量。但不知何故,它没有。
- 有趣的是,如果我
AdminSecurityGroup
用ServerSecurityGroup
, 作为堡垒,连接是可能的。显然,接下来是移除AdminSecurityGroup
和ClientSecurityGroup
移除FooStack
(不再有这些了)。 Foo
如果所有安全组都在内部引用,为什么一切都会启动LaunchTemplate
?