Golang Tigris Secrets

Hi, I am trying to setup Tigris, and I follow along the tutorial displayed on Tigris page.
I setup the storage, I setup 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””. I have then tried to print the secret directly from golang 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)
	}

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Hello @chilljalapeno - sorry for the late response. I assume you also have AWS_SECRET_ACCESS_KEY setup in 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
	}

	// 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("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.