Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release v2.2] Backport https://github.com/cortexproject/cortex/pull/4897 to fix IDM… #2871

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tempodb/backend/s3/awssdkauth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package s3

import (
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/defaults"
mcreds "github.com/minio/minio-go/v7/pkg/credentials"
"github.com/pkg/errors"
)

func NewAWSSDKAuth(region string) *AWSSDKAuth {
dc := defaults.Config().WithRegion(region)
creds := defaults.CredChain(dc, defaults.Handlers())
return &AWSSDKAuth{
creds: creds,
}
}

// AWSSDKAuth retrieves credentials from the aws-sdk-go.
type AWSSDKAuth struct {
creds *credentials.Credentials
}

// Retrieve retrieves the keys from the environment.
func (a *AWSSDKAuth) Retrieve() (mcreds.Value, error) {
val, err := a.creds.Get()
if err != nil {
return mcreds.Value{}, errors.Wrap(err, "retrieve AWS SDK credentials")
}
return mcreds.Value{
AccessKeyID: val.AccessKeyID,
SecretAccessKey: val.SecretAccessKey,
SessionToken: val.SessionToken,
SignerType: mcreds.SignatureV4,
}, nil
}

// IsExpired returns if the credentials have been retrieved.
func (a *AWSSDKAuth) IsExpired() bool {
return a.creds.IsExpired()
}
1 change: 1 addition & 0 deletions tempodb/backend/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ func createCore(cfg *Config, hedge bool) (*minio.Core, error) {
}

creds := credentials.NewChainCredentials([]credentials.Provider{
wrapCredentialsProvider(NewAWSSDKAuth(cfg.Region)),
wrapCredentialsProvider(&credentials.EnvAWS{}),
wrapCredentialsProvider(&credentials.Static{
Value: credentials.Value{
Expand Down