Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

fix: Ignore s3 "bucket not found" error #1172

Merged
merged 1 commit into from
Jul 7, 2022
Merged
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
16 changes: 13 additions & 3 deletions resources/services/s3/buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func fetchS3BucketsWorker(ctx context.Context, meta schema.ClientMeta, buckets <
wb := &WrappedBucket{Bucket: bucket, Region: "us-east-1"}
err := resolveS3BucketsAttributes(ctx, meta, wb)
if err != nil {
if !cl.IsNotFoundError(err) {
if !isBucketNotFoundError(cl, err) {
errs <- err
}
continue
Expand Down Expand Up @@ -542,7 +542,7 @@ func resolveS3BucketsAttributes(ctx context.Context, meta schema.ClientMeta, res
resource.Region = output
}
if err = resolveBucketLogging(ctx, meta, resource, resource.Region); err != nil {
if c.IsNotFoundError(err) {
if isBucketNotFoundError(c, err) {
return nil
}
return diag.WrapError(err)
Expand Down Expand Up @@ -763,7 +763,7 @@ func resolveBucketPublicAccessBlock(ctx context.Context, meta schema.ClientMeta,
})
if err != nil {
// If we received any error other than NoSuchPublicAccessBlockConfiguration, we return and error
if c.IsNotFoundError(err) {
if isBucketNotFoundError(c, err) {
return nil
}
if client.IgnoreAccessDeniedServiceDisabled(err) {
Expand Down Expand Up @@ -880,3 +880,13 @@ func resolveBucketOwnershipControls(ctx context.Context, meta schema.ClientMeta,
resource.OwnershipControls = stringArray
return nil
}

func isBucketNotFoundError(cl *client.Client, err error) bool {
if cl.IsNotFoundError(err) {
return true
}
if err.Error() == "bucket not found" {
return true
}
return false
}