@@ -3,6 +3,7 @@ package scaleway
3
3
import (
4
4
"errors"
5
5
"fmt"
6
+ "net/http"
6
7
"os"
7
8
"strings"
8
9
"time"
@@ -20,11 +21,12 @@ const (
20
21
defaultObjectBucketTimeout = 10 * time .Minute
21
22
)
22
23
23
- func newS3Client (region , accessKey , secretKey string ) (* s3.S3 , error ) {
24
+ func newS3Client (httpClient * http. Client , region , accessKey , secretKey string ) (* s3.S3 , error ) {
24
25
config := & aws.Config {}
25
26
config .WithRegion (region )
26
27
config .WithCredentials (credentials .NewStaticCredentials (accessKey , secretKey , "" ))
27
28
config .WithEndpoint ("https://s3." + region + ".scw.cloud" )
29
+ config .WithHTTPClient (httpClient )
28
30
if strings .ToLower (os .Getenv ("TF_LOG" )) == "debug" {
29
31
config .WithLogLevel (aws .LogDebugWithHTTPBody )
30
32
}
@@ -40,7 +42,7 @@ func newS3ClientFromMeta(meta *Meta) (*s3.S3, error) {
40
42
region , _ := meta .scwClient .GetDefaultRegion ()
41
43
accessKey , _ := meta .scwClient .GetAccessKey ()
42
44
secretKey , _ := meta .scwClient .GetSecretKey ()
43
- return newS3Client (region .String (), accessKey , secretKey )
45
+ return newS3Client (meta . httpClient , region .String (), accessKey , secretKey )
44
46
}
45
47
46
48
func s3ClientWithRegion (d * schema.ResourceData , m interface {}) (* s3.S3 , scw.Region , error ) {
@@ -53,7 +55,7 @@ func s3ClientWithRegion(d *schema.ResourceData, m interface{}) (*s3.S3, scw.Regi
53
55
accessKey , _ := meta .scwClient .GetAccessKey ()
54
56
secretKey , _ := meta .scwClient .GetSecretKey ()
55
57
56
- s3Client , err := newS3Client (region .String (), accessKey , secretKey )
58
+ s3Client , err := newS3Client (meta . httpClient , region .String (), accessKey , secretKey )
57
59
if err != nil {
58
60
return nil , "" , err
59
61
}
@@ -69,7 +71,7 @@ func s3ClientWithRegionAndName(m interface{}, name string) (*s3.S3, scw.Region,
69
71
}
70
72
accessKey , _ := meta .scwClient .GetAccessKey ()
71
73
secretKey , _ := meta .scwClient .GetSecretKey ()
72
- s3Client , err := newS3Client (region .String (), accessKey , secretKey )
74
+ s3Client , err := newS3Client (meta . httpClient , region .String (), accessKey , secretKey )
73
75
if err != nil {
74
76
return nil , "" , "" , err
75
77
}
0 commit comments