Cloud custodian policy to get all open ports of AWS EC2 instance

317 Views Asked by At

I want to list down all open ports for an ec2 instance using cloud custodian policy.. Is there a possible way to do this in single step

policies:
name: ec2-by-port
    resource: ec2
    filters:    
type: security-group
        match-resource: true
        key: FromPort
        value: 80
        key: ToPort
        value: 80

here is the policy file I tried, But I get all the ec2 instances instead of the instances filtered according to port openness.. Please help me with this

1

There are 1 best solutions below

1
On

The formatting of your policy seems wrong. This looks like it should do the trick.

policies:
  - name: ec2-by-port
    resource: ec2
    filters:    
      - type: security-group
        match-resource: true
        key: FromPort
        value: 80
        key: ToPort
        value: 80