diff --git a/workhorse/internal/upload/destination/objectstore/s3_client.go b/workhorse/internal/upload/destination/objectstore/s3_client.go index ca8e05c5feb2badb3f895bdd5242aab9a5b46087..210504ad396b2978ff3d0a499f56fe8bef1c4004 100644 --- a/workhorse/internal/upload/destination/objectstore/s3_client.go +++ b/workhorse/internal/upload/destination/objectstore/s3_client.go @@ -2,6 +2,7 @@ package objectstore import ( "context" + "os" "sync" "time" @@ -39,6 +40,7 @@ var ( // hours. To be safe, refresh AWS clients every 10 minutes. clientExpiration = 10 * time.Minute clientCache = &s3ClientCache{clients: make(map[config.S3Config]*s3Client)} + awsDebugEnabled = os.Getenv("AWS_DEBUG") == "1" ) func (c *s3Client) isExpired() bool { @@ -72,6 +74,10 @@ func setupS3Client(s3Credentials config.S3Credentials, s3Config config.S3Config) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) // lint:allow context.Background defer cancel() + if awsDebugEnabled { + options = append(options, awsConfig.WithClientLogMode(aws.LogRetries|aws.LogRequest|aws.LogResponse)) + } + cfg, err := awsConfig.LoadDefaultConfig(ctx, options...) if err != nil { return nil, err