Skip to content

Commit b703509

Browse files
committed
Problem: can't use anonymous S3 credentials
When trying to use S3 cache with anonymous credentials (for example, for importing publicly available layers), the cache is not used. Solution: enable anonymous credentials According to the API documentation: "If using the `NewFromConfig` constructor you'll need to explicitly set the `Credentials` member to nil, if the external config resolved a credential provider." Signed-off-by: Yurii Rashkovskii <[email protected]>
1 parent 75123c6 commit b703509

File tree

1 file changed

+4
-0
lines changed
  • cache/remotecache/s3

1 file changed

+4
-0
lines changed

cache/remotecache/s3/s3.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ func newS3Client(ctx context.Context, config Config) (*s3Client, error) {
360360
client := s3.NewFromConfig(cfg, func(options *s3.Options) {
361361
if config.AccessKeyID != "" && config.SecretAccessKey != "" {
362362
options.Credentials = credentials.NewStaticCredentialsProvider(config.AccessKeyID, config.SecretAccessKey, config.SessionToken)
363+
} else {
364+
// Setting `nil` for anonymous credentials as per
365+
// https://pkg.go.dev/github.com/aws/[email protected]/aws#AnonymousCredentials
366+
options.Credentials = nil
363367
}
364368
if config.EndpointURL != "" {
365369
options.UsePathStyle = config.UsePathStyle

0 commit comments

Comments
 (0)