Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 improve aws s3 buckets resource #4620

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading