Skip to content

Commit b2bc77b

Browse files
robellison-jepondzix
authored andcommitted
Add custom http client to helpers aws session
1 parent 10b43af commit b2bc77b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pkg/common/helpers.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"crypto/x509"
1919
"fmt"
2020
"hash"
21+
"net/http"
2122
"os"
2223
"time"
2324

@@ -33,11 +34,18 @@ import (
3334
// using the standard auth flow. We also have the ability to pass a role ARN
3435
// to allow for roles to be assumed in cross-account access flows.
3536
func GetAWSSession(region string, roleARN string, endpoint string) (sess *session.Session, cfg *aws.Config, accountID *string, err error) {
37+
transport := http.DefaultTransport.(*http.Transport).Clone()
38+
transport.MaxIdleConnsPerHost = transport.MaxIdleConns
39+
httpClient := &http.Client{
40+
Transport: transport,
41+
}
42+
3643
sess = session.Must(session.NewSessionWithOptions(session.Options{
3744
SharedConfigState: session.SharedConfigEnable,
3845
Config: aws.Config{
39-
Region: aws.String(region),
40-
Endpoint: aws.String(endpoint),
46+
Region: aws.String(region),
47+
Endpoint: aws.String(endpoint),
48+
HTTPClient: httpClient,
4149
},
4250
}))
4351

@@ -46,6 +54,7 @@ func GetAWSSession(region string, roleARN string, endpoint string) (sess *sessio
4654
cfg = &aws.Config{
4755
Credentials: creds,
4856
Region: aws.String(region),
57+
HTTPClient: httpClient,
4958
}
5059
}
5160

0 commit comments

Comments
 (0)