1- // Package awsconfig generates AWS client configurations optimized for use by
2- // the randomizer.
1+ // Package awsconfig provides a randomizer-optimized AWS SDK configuration.
32package awsconfig
43
54import (
@@ -37,10 +36,9 @@ type Option = func(*config.LoadOptions) error
3736func New (ctx context.Context ) (aws.Config , error ) {
3837 transport := http .DefaultTransport
3938
40- // This option is recommended in AWS Lambda deployments due to the
41- // significant reduction in cold start latency (see getEmbeddedCertPool).
42- // It can be enabled for standard server deployments if desired, but is far
43- // less beneficial.
39+ // This option is recommended in AWS Lambda to significantly reduce cold
40+ // start latency (see [getEmbeddedCertTransport]). It can be enabled for
41+ // standard server deployments if desired, but is far less beneficial.
4442 if os .Getenv ("AWS_CLIENT_EMBEDDED_TLS_ROOTS" ) == "1" {
4543 transport = getEmbeddedCertTransport ()
4644 }
@@ -60,10 +58,9 @@ func New(ctx context.Context) (aws.Config, error) {
6058 return aws.Config {}, fmt .Errorf ("loading AWS config: %w" , err )
6159 }
6260
63- // WARNING: X-Ray tracing will panic if the context passed to AWS operations
64- // is not already associated with an open X-Ray segment. That means that as of
65- // this writing this option is only safe to use on AWS Lambda. Standard server
66- // deployments should avoid setting it.
61+ // NOTE: X-Ray tracing panics if the context for an AWS call is not already
62+ // associated with an open X-Ray segment. As of writing, this option is only
63+ // safe to use on AWS Lambda. Standard server deployments should avoid it.
6764 if useXRay := os .Getenv ("AWS_CLIENT_XRAY_TRACING" ); useXRay == "1" {
6865 xrayawsv2 .AWSV2Instrumentor (& cfg .APIOptions )
6966 }
@@ -75,12 +72,11 @@ func New(ctx context.Context) (aws.Config, error) {
7572// CAs operated by Amazon Trust Services, which all AWS service endpoints chain
7673// from.
7774//
78- // When the randomizer runs on AWS Lambda in the recommended configuration, this
79- // limited set of roots is so much cheaper to parse than a typical set of system
80- // roots that it cuts cold start invocation time roughly in half (by around
81- // 500ms). This is a large enough difference for a human to notice, and accounts
82- // for about 15% of the 3 second response time limit that Slack imposes on slash
83- // commands.
75+ // When the randomizer runs on AWS Lambda with recommended resource settings,
76+ // this limited set of roots is substantially cheaper to parse than a typical
77+ // root store, which removes ~500ms of cold-start response latency. That's
78+ // large enough for a human to notice, and accounts for ~15% of the 3-second
79+ // response time limit Slack imposes on slash commands.
8480var getEmbeddedCertTransport = sync .OnceValue (func () * http.Transport {
8581 transport := http .DefaultTransport .(* http.Transport ).Clone ()
8682 transport .TLSClientConfig = & tls.Config {RootCAs : loadEmbeddedCertPool ()}
0 commit comments