Skip to content

Commit a3779e8

Browse files
authored
fix: Use Pagination for aws_ec2_images (#13560)
#### Summary Rather than returning all images in a single API call, this PR changes it to use pagination... It will return 1000 images at a time. This will improve performance for large accounts where it is faster to batch the results rather than return them all at once
1 parent f684ab9 commit a3779e8

File tree

1 file changed

+3
-1
lines changed
  • plugins/source/aws/resources/services/ec2

1 file changed

+3
-1
lines changed

plugins/source/aws/resources/services/ec2/images.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ func fetchEc2Images(ctx context.Context, meta schema.ClientMeta, parent *schema.
5454
g.Go(func() error {
5555
// fetch ec2.Images owned by this account
5656
pag := ec2.NewDescribeImagesPaginator(svc, &ec2.DescribeImagesInput{
57-
Owners: []string{"self"},
57+
Owners: []string{"self"},
58+
MaxResults: aws.Int32(1000),
5859
})
5960
for pag.HasMorePages() {
6061
resp, err := pag.NextPage(ctx, func(options *ec2.Options) {
@@ -72,6 +73,7 @@ func fetchEc2Images(ctx context.Context, meta schema.ClientMeta, parent *schema.
7273
// fetch ec2.Images that are shared with this account
7374
pag := ec2.NewDescribeImagesPaginator(svc, &ec2.DescribeImagesInput{
7475
ExecutableUsers: []string{"self"},
76+
MaxResults: aws.Int32(1000),
7577
})
7678
for pag.HasMorePages() {
7779
resp, err := pag.NextPage(ctx, func(options *ec2.Options) {

0 commit comments

Comments
 (0)