问题描述
我一直在四处寻找为什么我认为应该起作用的东西不起作用。 这是一个细分
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
因此,我试图允许来自BastionSecurityGroup@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"
无论如何,上面的那个组以后会链接到AWS::EC2::LaunchTemplate
中被最终引用的SecurityGroup。定义如下:
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
的所有安全组,为什么一切都会生效?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)