diff --git a/repo/blob/gcs/gcs_storage.go b/repo/blob/gcs/gcs_storage.go index b0fc0fb02..600eebebc 100644 --- a/repo/blob/gcs/gcs_storage.go +++ b/repo/blob/gcs/gcs_storage.go @@ -267,6 +267,11 @@ func New(ctx context.Context, opt *Options) (blob.Storage, error) { return nil, errors.New("bucket name must be specified") } + // make sure the bucket exists + if _, err := cli.Bucket(opt.BucketName).Attrs(ctx); err != nil { + return nil, errors.Wrap(err, "unable to read bucket") + } + return &gcsStorage{ Options: *opt, ctx: ctx, diff --git a/repo/blob/s3/s3_storage.go b/repo/blob/s3/s3_storage.go index f9194680a..27261e7a6 100644 --- a/repo/blob/s3/s3_storage.go +++ b/repo/blob/s3/s3_storage.go @@ -233,6 +233,15 @@ func New(ctx context.Context, opt *Options) (blob.Storage, error) { downloadThrottler := iothrottler.NewIOThrottlerPool(toBandwidth(opt.MaxDownloadSpeedBytesPerSecond)) uploadThrottler := iothrottler.NewIOThrottlerPool(toBandwidth(opt.MaxUploadSpeedBytesPerSecond)) + ok, err := cli.BucketExistsWithContext(ctx, opt.BucketName) + if err != nil { + return nil, errors.Wrapf(err, "unable to determine if bucket %q exists", opt.BucketName) + } + + if !ok { + return nil, errors.Errorf("bucket %q does not exist", opt.BucketName) + } + return &s3Storage{ Options: *opt, ctx: ctx,