benbjohnson/litestream · error
s3: cannot load aws config for region lookup: %w
Error message
s3: cannot load aws config for region lookup: %w
What it means
findBucketRegion's config.LoadDefaultConfig (a minimal config with credentials but no region) failed. Same class as main config load failure: broken shared AWS files, bad profile, or unreachable metadata service for the configured credential chain.
Source
Thrown at s3/replica_client.go:631
// findBucketRegion looks up the AWS region for a bucket. Returns blank if non-S3.
func (c *ReplicaClient) findBucketRegion(ctx context.Context, bucket string) (string, error) {
// Build a config with credentials but no region
configOpts := []func(*config.LoadOptions) error{
config.WithRetryer(newTransportRetryer),
}
// Add static credentials if provided
if c.AccessKeyID != "" && c.SecretAccessKey != "" {
configOpts = append(configOpts, config.WithCredentialsProvider(
credentials.NewStaticCredentialsProvider(c.AccessKeyID, c.SecretAccessKey, ""),
))
}
// Load AWS configuration
cfg, err := config.LoadDefaultConfig(ctx, configOpts...)
if err != nil {
return "", fmt.Errorf("s3: cannot load aws config for region lookup: %w", err)
}
// Use default region for initial region lookup
cfg.Region = DefaultRegion
// Create S3 client options
s3Opts := []func(*s3.Options){}
// Configure custom endpoint for region lookup
c.configureEndpoint(&s3Opts)
client := s3.NewFromConfig(cfg, s3Opts...)
// Get bucket location
out, err := client.GetBucketLocation(ctx, &s3.GetBucketLocationInput{
Bucket: aws.String(bucket),
})
if err != nil {View on GitHub (pinned to 4ed7a308f6)
Solutions
- Fix AWS shared config/credentials files
- Set region explicitly to skip the region lookup entirely
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at s3/replica_client.go:631 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06).
Data as JSON: /api/errors/1f8cc721a52c217a.
Report an issue: GitHub.