Skip to content

Commit d088f51

Browse files
committed
Remove extraOptions support from awsconfig
Endpoint customizations were the only reason this existed.
1 parent 1a2a0ca commit d088f51

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

internal/awsconfig/awsconfig.go

+12-17
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,30 @@ type Option = func(*config.LoadOptions) error
3434

3535
// New creates a new AWS client configuration using reasonable default settings
3636
// for timeouts and retries.
37-
func New(ctx context.Context, extraOptions ...Option) (aws.Config, error) {
37+
func New(ctx context.Context) (aws.Config, error) {
3838
transport := http.DefaultTransport.(*http.Transport).Clone()
3939

4040
// This option is recommended in AWS Lambda deployments due to the
4141
// 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.
4444
if os.Getenv("AWS_CLIENT_EMBEDDED_TLS_ROOTS") == "1" {
4545
transport.TLSClientConfig = &tls.Config{
4646
RootCAs: getEmbeddedCertPool(),
4747
}
4848
}
4949

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+
}),
5755
config.WithRetryer(
5856
func() aws.Retryer {
5957
return retry.AddWithMaxAttempts(retry.NewStandard(), DefaultRetryMaxAttempts)
6058
},
6159
),
62-
}
63-
options = append(options, extraOptions...)
64-
65-
cfg, err := config.LoadDefaultConfig(ctx, options...)
60+
)
6661
if err != nil {
6762
return aws.Config{}, fmt.Errorf("loading AWS config: %w", err)
6863
}
@@ -89,9 +84,9 @@ var embeddedRootsDER []byte
8984
// When the randomizer runs on AWS Lambda in the recommended configuration,
9085
// this limited set of roots is so much cheaper to parse than the full set of
9186
// 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.
9590
var getEmbeddedCertPool = sync.OnceValue(func() *x509.CertPool {
9691
certs, err := x509.ParseCertificates(embeddedRootsDER)
9792
if err != nil {

0 commit comments

Comments
 (0)