@@ -34,35 +34,30 @@ type Option = func(*config.LoadOptions) error
34
34
35
35
// New creates a new AWS client configuration using reasonable default settings
36
36
// for timeouts and retries.
37
- func New (ctx context.Context , extraOptions ... Option ) (aws.Config , error ) {
37
+ func New (ctx context.Context ) (aws.Config , error ) {
38
38
transport := http .DefaultTransport .(* http.Transport ).Clone ()
39
39
40
40
// This option is recommended in AWS Lambda deployments due to the
41
41
// significant reduction in cold start latency (see getEmbeddedCertPool).
42
- // It can be enabled for standard server deployments if desired, but is
43
- // likely far less beneficial.
42
+ // It can be enabled for standard server deployments if desired, but is far
43
+ // less beneficial.
44
44
if os .Getenv ("AWS_CLIENT_EMBEDDED_TLS_ROOTS" ) == "1" {
45
45
transport .TLSClientConfig = & tls.Config {
46
46
RootCAs : getEmbeddedCertPool (),
47
47
}
48
48
}
49
49
50
- client := & http.Client {
51
- Timeout : DefaultTimeout ,
52
- Transport : transport ,
53
- }
54
-
55
- options := []Option {
56
- config .WithHTTPClient (client ),
50
+ cfg , err := config .LoadDefaultConfig (ctx ,
51
+ config .WithHTTPClient (& http.Client {
52
+ Timeout : DefaultTimeout ,
53
+ Transport : transport ,
54
+ }),
57
55
config .WithRetryer (
58
56
func () aws.Retryer {
59
57
return retry .AddWithMaxAttempts (retry .NewStandard (), DefaultRetryMaxAttempts )
60
58
},
61
59
),
62
- }
63
- options = append (options , extraOptions ... )
64
-
65
- cfg , err := config .LoadDefaultConfig (ctx , options ... )
60
+ )
66
61
if err != nil {
67
62
return aws.Config {}, fmt .Errorf ("loading AWS config: %w" , err )
68
63
}
@@ -89,9 +84,9 @@ var embeddedRootsDER []byte
89
84
// When the randomizer runs on AWS Lambda in the recommended configuration,
90
85
// this limited set of roots is so much cheaper to parse than the full set of
91
86
// roots trusted by Amazon Linux 2 that it cuts invocation time on cold starts
92
- // approximately in half, specifically by around 500ms. This is a large enough
93
- // difference for a human to notice, and accounts for about 15% of the 3 second
94
- // response time limit that Slack imposes on slash commands.
87
+ // approximately in half ( by around 500ms) . This is a large enough difference
88
+ // for a human to notice, and accounts for about 15% of the 3 second response
89
+ // time limit that Slack imposes on slash commands.
95
90
var getEmbeddedCertPool = sync .OnceValue (func () * x509.CertPool {
96
91
certs , err := x509 .ParseCertificates (embeddedRootsDER )
97
92
if err != nil {
0 commit comments