remotion-dev/remotion · error · error
could not get location of S3 bucket %q: %w
Error message
could not get location of S3 bucket %q: %w
What it means
Returned by isBucketInRegion when GetBucketLocation fails for a reason other than NoSuchBucket (that one is swallowed and treated as 'not in region'). The %w carries the underlying AWS error. Most often this is a permissions issue: the caller can list bucket names but cannot call GetBucketLocation on a specific bucket.
Source
Thrown at packages/lambda-go/s3.go:87
config.WithRegion(region),
)
if err != nil {
return nil, fmt.Errorf("could not load AWS config: %w", err)
}
return s3.NewFromConfig(awsConfig, func(options *s3.Options) {
options.UsePathStyle = forcePathStyle
}), nil
}
// isBucketInRegion reports whether the given bucket lives in region.
func isBucketInRegion(svc bucketLocationGetter, bucket string, region string) (bool, error) {
out, err := svc.GetBucketLocation(context.TODO(), &s3.GetBucketLocationInput{Bucket: new(bucket)})
if err != nil {
var awsErr smithy.APIError
if errors.As(err, &awsErr) && awsErr.ErrorCode() == "NoSuchBucket" {
return false, nil
}
return false, fmt.Errorf("could not get location of S3 bucket %q: %w", bucket, err)
}
location := string(out.LocationConstraint)
return location == region || (location == "" && region == regionUsEast1), nil
}
// getRemotionBuckets lists the Remotion buckets that exist in region.
func getRemotionBuckets(svc *s3.Client, region string) ([]string, error) {
out, err := svc.ListBuckets(context.TODO(), &s3.ListBucketsInput{})
if err != nil {
return nil, fmt.Errorf("could not list S3 buckets: %w", err)
}
buckets := []string{}
for _, bucket := range out.Buckets {
name := aws.ToString(bucket.Name)
if !strings.HasPrefix(name, bucketNamePrefix) {
continue
}
isInRegion, err := isBucketInRegion(svc, name, region)View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Grant s3:GetBucketLocation on `arn:aws:s3:::*` in the caller's IAM policy.
- Inspect the wrapped smithy.APIError code: AccessDenied → add the permission; AuthorizationHeaderMalformed → check endpoint/region; PermanentRedirect → bucket is in a different region.
- If the bucket is foreign, delete it or migrate so only one Remotion-managed bucket remains.
Defensive patterns
Strategy: try-catch
Try / catch
inRegion, err := isBucketInRegion(svc, name, region)
if err != nil {
var awsErr smithy.APIError
if errors.As(err, &awsErr) && awsErr.ErrorCode() == "AccessDenied" {
// caller can list but not GetBucketLocation: add s3:GetBucketLocation
}
return err
} Prevention
- Grant s3:GetBucketLocation on `arn:aws:s3:::*` in the caller's IAM policy.
- Avoid leaving stale foreign `remotionlambda-` buckets in the account.
- Test the IAM policy against a real bucket before deploying.
When it happens
Trigger: svc.GetBucketLocation returns a non-NoSuchBucket error — typically AccessDenied, PermanentRedirect (bucket in a different account/region requiring a different endpoint), or a transport error. The function re-raises the wrapped error.
Common situations: IAM policy grants s3:ListAllMyBuckets but not s3:GetBucketLocation. A `remotionlambda-` bucket exists in the account but was created by a different principal whose bucket policy denies the caller. Network egress to S3 is intermittent.
Related errors
- could not list S3 buckets: %w
- failed to create bucket: %w
- you have multiple buckets (%s) in your S3 region (%s) starti
- failed to upload inputProps to S3: %w
- could not invoke Lambda function %q: %w
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/4d4ed8aceace8328.
Report an issue: GitHub.