@@ -23,25 +23,28 @@ func init() {
23
23
24
24
func ListEC2SecurityGroups (sess * session.Session ) ([]Resource , error ) {
25
25
svc := ec2 .New (sess )
26
+ resources := make ([]Resource , 0 )
26
27
27
28
params := & ec2.DescribeSecurityGroupsInput {}
28
- resp , err := svc .DescribeSecurityGroups (params )
29
+ err := svc .DescribeSecurityGroupsPages (params ,
30
+ func (page * ec2.DescribeSecurityGroupsOutput , lastPage bool ) bool {
31
+ for _ , group := range page .SecurityGroups {
32
+ resources = append (resources , & EC2SecurityGroup {
33
+ svc : svc ,
34
+ group : group ,
35
+ id : group .GroupId ,
36
+ name : group .GroupName ,
37
+ ingress : group .IpPermissions ,
38
+ egress : group .IpPermissionsEgress ,
39
+ })
40
+ }
41
+ return ! lastPage
42
+ })
43
+
29
44
if err != nil {
30
45
return nil , err
31
46
}
32
47
33
- resources := make ([]Resource , 0 )
34
- for _ , group := range resp .SecurityGroups {
35
- resources = append (resources , & EC2SecurityGroup {
36
- svc : svc ,
37
- group : group ,
38
- id : group .GroupId ,
39
- name : group .GroupName ,
40
- ingress : group .IpPermissions ,
41
- egress : group .IpPermissionsEgress ,
42
- })
43
- }
44
-
45
48
return resources , nil
46
49
}
47
50
@@ -86,11 +89,11 @@ func (sg *EC2SecurityGroup) Remove() error {
86
89
87
90
func (sg * EC2SecurityGroup ) Properties () types.Properties {
88
91
properties := types .NewProperties ()
89
- for _ , tagValue := range sg .group .Tags {
90
- properties .SetTag (tagValue .Key , tagValue .Value )
91
- }
92
- properties .Set ("Name" , sg .name )
93
- return properties
92
+ for _ , tagValue := range sg .group .Tags {
93
+ properties .SetTag (tagValue .Key , tagValue .Value )
94
+ }
95
+ properties .Set ("Name" , sg .name )
96
+ return properties
94
97
}
95
98
96
99
func (sg * EC2SecurityGroup ) String () string {
0 commit comments