Skip to content

Commit

Permalink
Fix the not found error code in the getBucketTagging and getBucketWeb…
Browse files Browse the repository at this point in the history
…site functions Closes #2334 (#2335)
  • Loading branch information
ParthaI authored Nov 18, 2024
1 parent 380626e commit 504c16e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions aws/table_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ func tableAwsS3Bucket(_ context.Context) *plugin.Table {
Hydrate: listS3Buckets,
Tags: map[string]string{"service": "s3", "action": "ListBucket"},
},

// Note: No Get for S3 buckets, since it must list all the buckets
// anyway just to get the creation_date which is only available via the
// list call.

// Using IgnoreConfig in the Hydrate function has been observed to increase query execution time significantly.
// Therefore, we have opted not to use IgnoreConfig in Hydrate calls to maintain optimal performance.
// Example: For the query "select * from aws_s3_bucket where region = 'us-east-2'",
// using IgnoreConfig results in a slower execution time of 87.2 seconds, while handling errors manually reduces the time to 25.0 seconds.
HydrateConfig: []plugin.HydrateConfig{
{
Func: getBucketRegion,
Expand Down Expand Up @@ -691,6 +697,12 @@ func getBucketTagging(ctx context.Context, d *plugin.QueryData, h *plugin.Hydrat

bucketTags, err := svc.GetBucketTagging(ctx, params)
if err != nil {
var ae smithy.APIError
if errors.As(err, &ae) {
if ae.ErrorCode() == "NoSuchTagSet" {
return nil, nil
}
}
plugin.Logger(ctx).Error("aws_s3_bucket.getBucketTagging", "api_error", err)
return nil, err
}
Expand All @@ -713,6 +725,12 @@ func getBucketWebsite(ctx context.Context, d *plugin.QueryData, h *plugin.Hydrat

bucketwebsites, err := svc.GetBucketWebsite(ctx, params)
if err != nil {
var ae smithy.APIError
if errors.As(err, &ae) {
if ae.ErrorCode() == "NoSuchWebsiteConfiguration" {
return nil, nil
}
}
plugin.Logger(ctx).Error("aws_s3_bucket.getBucketWebsite", "api_error", err)
return nil, err
}
Expand Down

0 comments on commit 504c16e

Please sign in to comment.