Skip to content

Commit 0ca00da

Browse files
author
Marco Franceschi
committed
feat: Set onfigurable limit for s3 list objects
1 parent 97b1e23 commit 0ca00da

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/services/s3/data.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,11 @@ const getBucketAdditionalInfo = async (s3: S3, name: BucketName) =>
394394
})
395395
})
396396

397-
const listBucketsForRegion = async (s3: S3, resolveRegion: () => void) =>
398-
new Promise<{ buckets: Bucket[]; ownerId: Owner }>(resolve => {
397+
const listBucketsForRegion = async (
398+
s3: S3,
399+
resolveRegion: () => void
400+
): Promise<{ buckets: Bucket[]; ownerId: Owner }> =>
401+
new Promise(resolve => {
399402
s3.listBuckets((err: AWSError, data: ListBucketsOutput) => {
400403
/**
401404
* No Data for the region
@@ -424,16 +427,20 @@ const listBucketsForRegion = async (s3: S3, resolveRegion: () => void) =>
424427
})
425428
})
426429

427-
const listBucketObjects = async (s3: S3, name: BucketName) =>
428-
new Promise<S3Object[]>(resolve => {
430+
const listBucketObjects = async (
431+
s3: S3,
432+
name: BucketName,
433+
params?: { [field: string]: any }
434+
): Promise<S3Object[]> =>
435+
new Promise(resolve => {
429436
const contents: S3Object[] = []
430437
/**
431438
* S3 Buckets can get quite large, so we limit the total number
432439
* Of objects returned per bucket to 1000
433440
*/
434441
const opts: any = {
435442
Bucket: name,
436-
MaxKeys: awsBucketItemsLimit,
443+
...(params ?? { MaxKeys: awsBucketItemsLimit }),
437444
}
438445
const listAllObjects = (token?: string) => {
439446
if (token) {
@@ -495,9 +502,11 @@ export interface RawAwsS3 {
495502
export default async ({
496503
regions,
497504
config,
505+
params,
498506
}: {
499507
regions: string
500508
config: Config
509+
params: any
501510
}): Promise<{
502511
[region: string]: RawAwsS3[]
503512
}> =>
@@ -552,7 +561,11 @@ export default async ({
552561
s3ForcePathStyle: true,
553562
})
554563
logger.debug(lt.gettingBucketBasicInfo(Name))
555-
const bucketObjectList: S3Object[] = await listBucketObjects(s3, Name)
564+
const bucketObjectList: S3Object[] = await listBucketObjects(
565+
s3,
566+
Name,
567+
params
568+
)
556569

557570
bucketData[idx].Contents = []
558571
if (!isEmpty(bucketObjectList)) {

src/types/generated.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4212,8 +4212,12 @@ export type AwsTransitGateway = AwsBaseService & {
42124212
vpnEcmpSupport?: Maybe<Scalars['String']>;
42134213
};
42144214

4215-
export type AwsTransitGatewayAttachment = AwsBaseService & {
4215+
export type AwsTransitGatewayAttachment = {
4216+
accountId: Scalars['String'];
4217+
arn: Scalars['String'];
42164218
creationTime?: Maybe<Scalars['String']>;
4219+
id: Scalars['String'];
4220+
region?: Maybe<Scalars['String']>;
42174221
resourceId?: Maybe<Scalars['String']>;
42184222
resourceOwnerId?: Maybe<Scalars['String']>;
42194223
resourceType?: Maybe<Scalars['String']>;

0 commit comments

Comments
 (0)