Skip to content

Commit a7cd8a4

Browse files
eduardodbrisubasinghe
authored andcommitted
fix: S3 artifacts failing with missing region when using roleARN (#14761)
Signed-off-by: Eduardo Rodrigues <[email protected]>
1 parent 38f6433 commit a7cd8a4

File tree

1 file changed

+5
-6
lines changed
  • workflow/artifacts/s3

1 file changed

+5
-6
lines changed

workflow/artifacts/s3/s3.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,8 @@ func GetAWSCredentials(opts S3ClientOpts) (*credentials.Credentials, error) {
408408
}
409409

410410
// GetAssumeRoleCredentials gets Assumed role credentials
411-
func GetAssumeRoleCredentials(opts S3ClientOpts) (*credentials.Credentials, error) {
412-
ctx := context.Background()
413-
cfg, err := config.LoadDefaultConfig(ctx)
411+
func getAssumeRoleCredentials(ctx context.Context, opts S3ClientOpts) (*credentials.Credentials, error) {
412+
cfg, err := config.LoadDefaultConfig(ctx, config.WithRegion(opts.Region))
414413
if err != nil {
415414
return nil, err
416415
}
@@ -427,7 +426,7 @@ func GetAssumeRoleCredentials(opts S3ClientOpts) (*credentials.Credentials, erro
427426
return credentials.NewStaticV4(value.AccessKeyID, value.SecretAccessKey, value.SessionToken), nil
428427
}
429428

430-
func GetCredentials(opts S3ClientOpts) (*credentials.Credentials, error) {
429+
func GetCredentials(ctx context.Context, opts S3ClientOpts) (*credentials.Credentials, error) {
431430
if opts.AccessKey != "" && opts.SecretKey != "" {
432431
if opts.SessionToken != "" {
433432
log.WithField("endpoint", opts.Endpoint).Info("Creating minio client using ephemeral credentials")
@@ -438,7 +437,7 @@ func GetCredentials(opts S3ClientOpts) (*credentials.Credentials, error) {
438437
}
439438
} else if opts.RoleARN != "" {
440439
log.WithField("roleArn", opts.RoleARN).Info("Creating minio client using assumed-role credentials")
441-
return GetAssumeRoleCredentials(opts)
440+
return getAssumeRoleCredentials(ctx, opts)
442441
} else if opts.UseSDKCreds {
443442
log.Info("Creating minio client using AWS SDK credentials")
444443
return GetAWSCredentials(opts)
@@ -463,7 +462,7 @@ func NewS3Client(ctx context.Context, opts S3ClientOpts) (S3Client, error) {
463462
var minioClient *minio.Client
464463
var err error
465464

466-
credentials, err := GetCredentials(opts)
465+
credentials, err := GetCredentials(ctx, opts)
467466
if err != nil {
468467
return nil, err
469468
}

0 commit comments

Comments
 (0)