feat: allow for IRSA with s3
Signed-off-by: David van der Spek <vanderspek.david@gmail.com>
This commit is contained in:
parent
7c354a4b40
commit
347f6c377a
1 changed files with 8 additions and 15 deletions
|
@ -29,8 +29,6 @@ import (
|
|||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
||||
"github.com/aws/aws-sdk-go/aws/credentials/ec2rolecreds"
|
||||
"github.com/aws/aws-sdk-go/aws/ec2metadata"
|
||||
"github.com/aws/aws-sdk-go/aws/endpoints"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
|
@ -409,25 +407,20 @@ func New(params DriverParameters) (*Driver, error) {
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create new session: %v", err)
|
||||
}
|
||||
creds := credentials.NewChainCredentials([]credentials.Provider{
|
||||
&credentials.StaticProvider{
|
||||
Value: credentials.Value{
|
||||
AccessKeyID: params.AccessKey,
|
||||
SecretAccessKey: params.SecretKey,
|
||||
SessionToken: params.SessionToken,
|
||||
},
|
||||
},
|
||||
&credentials.EnvProvider{},
|
||||
&credentials.SharedCredentialsProvider{},
|
||||
&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(sess)},
|
||||
})
|
||||
if params.AccessKey != "" && params.SecretKey != "" {
|
||||
creds := credentials.NewStaticCredentials(
|
||||
params.AccessKey,
|
||||
params.SecretKey,
|
||||
params.SessionToken,
|
||||
)
|
||||
awsConfig.WithCredentials(creds)
|
||||
}
|
||||
|
||||
if params.RegionEndpoint != "" {
|
||||
awsConfig.WithS3ForcePathStyle(true)
|
||||
awsConfig.WithEndpoint(params.RegionEndpoint)
|
||||
}
|
||||
|
||||
awsConfig.WithCredentials(creds)
|
||||
awsConfig.WithRegion(params.Region)
|
||||
awsConfig.WithDisableSSL(!params.Secure)
|
||||
|
||||
|
|
Loading…
Reference in a new issue