Skip to content

Commit

Permalink
🧹 use paginator for s3 resource, fix region error on lambda function (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeffrey authored Sep 16, 2024
1 parent 839eff8 commit da118d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
13 changes: 7 additions & 6 deletions providers/aws/resources/aws_lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,15 @@ func initAwsLambdaFunction(runtime *plugin.Runtime, args map[string]*llx.RawData

name := args["name"]
region := args["region"]
if name == nil {
return nil, nil, errors.New("name required to fetch lambda function")
}
if region == nil {
return nil, nil, errors.New("region required to fetch lambda function")
}

var arnVal string
if args["arn"] == nil {
if name == nil {
return nil, nil, errors.New("name required to fetch lambda function")
}
if region == nil {
return nil, nil, errors.New("region required to fetch lambda function")
}
arnVal = getLambdaArn(name.String(), region.String(), "")
if arnVal == "" {
return nil, nil, errors.New("arn required to fetch lambda function")
Expand Down
18 changes: 13 additions & 5 deletions providers/aws/resources/aws_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,22 @@ func (a *mqlAwsS3) buckets() ([]interface{}, error) {
svc := conn.S3("")
ctx := context.Background()

buckets, err := svc.ListBuckets(ctx, &s3.ListBucketsInput{})
if err != nil {
return nil, err
totalBuckets := make([]s3types.Bucket, 0)
params := &s3.ListBucketsInput{}
paginator := s3.NewListBucketsPaginator(svc, params, func(o *s3.ListBucketsPaginatorOptions) {
o.Limit = 100
})
for paginator.HasMorePages() {
output, err := paginator.NextPage(context.TODO())
if err != nil {
return nil, err
}
totalBuckets = append(totalBuckets, output.Buckets...)
}

res := []interface{}{}
for i := range buckets.Buckets {
bucket := buckets.Buckets[i]
for i := range totalBuckets {
bucket := totalBuckets[i]

location, err := svc.GetBucketLocation(ctx, &s3.GetBucketLocationInput{
Bucket: bucket.Name,
Expand Down

0 comments on commit da118d0

Please sign in to comment.