Golang Tigris Secrets - Tigris

Golang Tigris Secrets

Hi, I am trying to set up Tigris, and I follow along the tutorial displayed on the Tigris page.

I set up the storage, I set up secrets, and I try to do a simple listing of the buckets from Tigris. For some reason that I do not know, Tigris does not read the secrets properly. I have tried printing the secrets myself to see if they are there and they are; I used fly ssh console -C "printenv"``fly ssh console -C "printenv". I then tried to print the secret directly from Go with:

log.Println(os.Getenv("AWS_ACCESS_KEY_ID"))

and it works.

sdkConfig, err := config.LoadDefaultConfig(context.TODO())

→ This fails to get my secrets. Can anyone help me understand why this fails.

sdkConfig, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
    log.Printf("Couldn't load default configuration. Here's why: %v\n", err)
    return
}

// Create S3 service client
svc := s3.NewFromConfig(sdkConfig, func(o *s3.Options) {
    o.BaseEndpoint = aws.String("https://fly.storage.tigris.dev")
    o.Region = "auto"
})

result, err := svc.ListObjectsV2(context.TODO(), &s3.ListObjectsV2Input{Bucket: aws.String("bucketName")})
if err != nil {
    log.Printf("Unable to list buckets. Here's why: %v\n", err)
}

log.Println("Contents:")

for _, b := range result.Contents {
    log.Printf("key=%s size=%d\n", aws.ToString(b.Key), b.Size)
}

Hello, sorry for the late response. I assume you also have AWS_SECRET_ACCESS_KEY``AWS_SECRET_ACCESS_KEY set up in an environment variable.

I tried with the same code with these imports:

import (
    "context"
    "log"

"github.com/aws/aws-sdk-go-v2/aws"
    "github.com/aws/aws-sdk-go-v2/config"
    "github.com/aws/aws-sdk-go-v2/service/s3"
)

func listBuckets() {
    sdkConfig, err := config.LoadDefaultConfig(context.TODO())
    if err != nil {
        log.Printf("Couldn't load default configuration. Here's why: %v\n", err)
        return
    }

result, err := svc.ListObjectsV2(context.TODO(), &s3.ListObjectsV2Input{Bucket: aws.String("jmj-test-bucket")})
    if err != nil {
        log.Printf("Unable to list buckets. Here's why: %v\n", err)
    }

log.Println("Contents:")
    for _, b := range result.Contents {
        log.Printf("key=%s size=%d\n", aws.ToString(b.Key), b.Size)
    }
}

and this works fine.