Skip to content

Commit f4bab31

Browse files
authored
handle aws endpoint env var (#2362)
1 parent f7ef7a6 commit f4bab31

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

taco/internal/storage/s3store.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,18 @@ type s3Store struct {
3434

3535
// NewS3Store creates a new S3-backed unit store.
3636
// Region can be empty to use the default AWS config chain.
37+
// Supports custom endpoints via AWS_ENDPOINT environment variable (for Tigris, MinIO, etc.)
3738
func NewS3Store(ctx context.Context, bucket, prefix, region string) (UnitStore, error) {
3839
if bucket == "" {
3940
return nil, fmt.Errorf("s3 bucket is required")
4041
}
42+
4143
var (
4244
cfg aws.Config
4345
err error
4446
)
47+
48+
// Load default config with region
4549
if region != "" {
4650
cfg, err = config.LoadDefaultConfig(ctx, config.WithRegion(region))
4751
} else {
@@ -50,7 +54,25 @@ func NewS3Store(ctx context.Context, bucket, prefix, region string) (UnitStore,
5054
if err != nil {
5155
return nil, err
5256
}
53-
cli := s3.NewFromConfig(cfg)
57+
58+
// Check for custom endpoint (for S3-compatible storage like Tigris, MinIO, etc.)
59+
endpoint := os.Getenv("AWS_ENDPOINT")
60+
var cli *s3.Client
61+
62+
if endpoint != "" {
63+
// Use custom endpoint for S3-compatible storage
64+
cli = s3.NewFromConfig(cfg, func(o *s3.Options) {
65+
o.BaseEndpoint = aws.String(endpoint)
66+
// Force path-style addressing for S3-compatible storage
67+
o.UsePathStyle = true
68+
})
69+
fmt.Printf("S3Store: Using custom endpoint: %s (path-style)\n", endpoint)
70+
} else {
71+
// Standard AWS S3
72+
cli = s3.NewFromConfig(cfg)
73+
fmt.Printf("S3Store: Using AWS S3 in region: %s\n", cfg.Region)
74+
}
75+
5476
return &s3Store{client: cli, bucket: bucket, prefix: strings.Trim(prefix, "/")}, nil
5577
}
5678

0 commit comments

Comments
 (0)