-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathawsconfig.go
More file actions
57 lines (44 loc) · 1.8 KB
/
awsconfig.go
File metadata and controls
57 lines (44 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package awsmocker
import (
"context"
"net/http"
"time"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
// awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http"
)
// If your application is setup to where you can provide an aws.Config object for your clients,
// then using the one provided by this method will make testing much easier.
func (m *mocker) buildAwsConfig(opts ...AwsLoadOptionsFunc) aws.Config {
// httpClient := awshttp.NewBuildableClient().WithTimeout(10 * time.Second).WithTransportOptions(func(t *http.Transport) {
// proxyUrl, _ := url.Parse(m.httpServer.URL)
// t.Proxy = http.ProxyURL(proxyUrl)
// // remove the need for CA bundle?
// // t.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
// })
// _ = httpClient
c := &http.Client{
Transport: m,
Timeout: 2 * time.Second,
}
options := make([]AwsLoadOptionsFunc, 0, 15)
options = append(options, config.WithDisableRequestCompression(aws.Bool(true)))
options = append(options, config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider("XXfakekey", "XXfakesecret", "xxtoken")))
options = append(options, config.WithDefaultRegion(DefaultRegion))
// options = append(options, config.WithHTTPClient(httpClient))
// options = append(options, config.WithHTTPClient(m))
options = append(options, config.WithHTTPClient(c))
// options = append(options, config.WithCustomCABundle(bytes.NewReader(caCert)))
options = append(options, config.WithRetryer(func() aws.Retryer {
return aws.NopRetryer{}
}))
// apply the options the user wanted
options = append(options, opts...)
options = append(options, addMiddlewareConfigOption(m))
cfg, err := config.LoadDefaultConfig(context.TODO(), options...)
if err != nil {
panic(err)
}
return cfg
}