问题描述
我需要获取连接了安全组的ec2实例,并需要检查那些安全组的规则是否超过50个。
我尝试了以下策略,但仍无法获得IpPermissions和IpPermisionsEgress的总和。
policies:
- name: ec2-instances-with-large-number-of-rules
resource: ec2
filters:
-and:
- type: security-group
key: IpPermissions[]
value_type: size
- type: security-group
key: IpPermissionsEgress[]
value_type: size
解决方法
您可以在所有保管策略中使用jmespath函数。我不确定这是否可以与EC2实例上的安全组过滤器一起使用。
我会尝试:
policies:
- name: security-groups-with-large-number-of-rules
resource: ec2
filters:
- type: security-group
key: sum([length(IpPermissions[],length(IpPermissionsEgress[]])
value_type: int
value: 50
op: gte
或通过使用相似的模式通过大量规则识别SG来攻击它