This document captures notable changes from AWS SDK for JavaScript v2 to v3. The v3 is also known as modular AWS SDK for JavaScript.
Because v3 is a modular rewrite of v2, some basic conceptions are different between v2 and v3. You can learn about these changes in our blog posts. The following blog posts will get you up to speed:
- Modular packages in AWS SDK for JavaScript
- Introducing Middleware Stack in Modular AWS SDK for JavaScript
The summary of interface changes from AWS SDK for JavaScript v2 to v3 is given below. The goal is to help you easily find the v3 equivalents of the v2 APIs you are already familiar with.
This list is indexed by v2 config parameters. For
options shown as Planned
in v3, they will be supported but no timeline can be shared at the moment. They
might not have the same name either.
-
- v2: Whether to compute MD5 checksums for payload bodies when the service accepts it (currently supported in S3 only).
- v3: Not available. Planned.
-
- v2: Whether types are converted when parsing response data.
- v3: Deprecated. This option is considered not type-safe because it doesn't convert the types like time stamp or base64 binaries from the JSON response.
-
- v2: Whether to apply a clock skew correction and retry requests that fail because of an skewed client clock.
- v3: Deprecated. SDK always applies a clock skew correction.
-
- v2: An offset value in milliseconds to apply to all signing times.
- v3: No change.
-
- v2: The AWS credentials to sign requests with.
- v3: No change. It can also be an async function that returns credentials. See v3 reference for AwsAuthInputConfig credentials.
-
- v2: The size of the global cache storing endpoints from endpoint discovery operations.
- v3: Not available. Planned. This option configures endpoint discovery behavior, which is not yet available in v3.
-
- v2: Whether to call operations with endpoints given by service dynamically.
- v3: Not available. Planned. This option configures endpoint discovery behavior, which is not yet available in v3.
-
- v2: Whether to marshal request parameters to the prefix of hostname.
- v3: Deprecated. SDK always injects the hostname prefix when necessary.
-
A set of options to pass to the low-level HTTP request. These options are aggregated differently in v3. You can configure them by supplying a new
requestHandler
. Here's the example of setting http options in Node.js runtime. You can find more in v3 reference for NodeHttpHandler.All v3 requests use HTTPS by default. You only need to provide custom httpsAgent.
const { Agent } = require("https"); const { Agent: HttpAgnet } = require("http"); const { NodeHttpHandler } = require("@aws-sdk/node-http-handler"); const dynamodbClient = new DynamoDBClient({ requestHandler: new NodeHttpHandler({ httpsAgent: new Agent({ /*params*/ }), connectionTimeout: /*number in milliseconds*/ socketTimeout: /*number in milliseconds*/ }), });
If you are passing custom endpoint which uses http, then you need to provide httpAgent.
const { Agent } = require("http"); const { NodeHttpHandler } = require("@aws-sdk/node-http-handler"); const dynamodbClient = new DynamoDBClient({ requestHandler: new NodeHttpHandler({ httpAgent: new Agent({ /*params*/ }), }), endpoint: "http://example.com", });
If the client is running in browsers, a different set of options is available. You can find more in v3 reference for FetchHttpHandler.
const { FetchHttpHandler } = require("@aws-sdk/fetch-http-handler"); const dynamodbClient = new DynamoDBClient({ requestHandler: new FetchHttpHandler({ requestTimeout: /*number in milliseconds*/ }), });
Each option of
httpOptions
is specified below:-
proxy
- v2: The URL to proxy requests through
- v3: You can set up a proxy with an agent following Configuring proxies for Node.js
-
agent
- v2: The Agent object to perform HTTP requests with. Used for connection pooling.
- v3: You can configure
httpAgent
orhttpsAgent
as shown in the examples above.
-
connectionTimeout
- v2: Sets the socket to timeout after failing to establish a connection with the server after connectTimeout milliseconds.
- v3:
connectionTimeout
is available inNodeHttpHandler
options.
-
timeout
- v2: The number of milliseconds a request can take before automatically being terminated.
- v3: Hard request timeout is not available in
NodeHttpHandler
, but available asrequestTimeout
inFetchHttphandler
in browsers
-
xhrAsync
- v2: Whether the SDK will send asynchronous HTTP requests.
- v3: Deprecated. Requests are always asynchronous.
-
xhrWithCredentials
- v2: Sets the "withCredentials" property of an XMLHttpRequest object.
- v3: Not available. SDK inherits the default fetch configurations
-
-
- v2: An object that responds to .write() (like a stream) or .log() (like the console object) in order to log information about requests.
- v3: No change. More granular logs are available in v3.
-
- v2: The maximum amount of redirects to follow for a service request.
- v3: Deprecated. SDK does not follow redirects to avoid unintentional cross-region requests.
-
- v2: The maximum amount of retries to perform for a service request.
- v3: Changed to
maxAttempts
. See more in v3 reference for RetryInputConfig. Note that themaxAttempt
should bemaxRetries + 1
.
-
- v2: Whether input parameters should be validated against the operation description before sending the request.
- v3: Deprecated. SDK does not do validation on client-side at runtime.
-
- v2: The region to send service requests to.
- v3: No change. It can also be an async function that returns a region string.
-
- v2: A set of options to configure the retry delay on retryable errors.
- v3: Deprecated. SDK supports more flexible retry strategy with
retryStrategy
client constructor option. See more in v3 reference
-
- v2: Whether the provided endpoint addresses an individual bucket (false if it addresses the root API endpoint).
- v3: Renamed to
bucketEndpoint
-
- v2: Whether to disable S3 body signing when using signature version v4.
- v3: Renamed to
applyChecksum
-
- v2: Whether to force path style URLs for S3 objects.
- v3: Renamed to
forcePathStyle
-
- v2: Whether to override the request region with the region inferred from requested resource's ARN.
- v3: Renamed to
useArnRegion
-
- v2: When region is set to 'us-east-1', whether to send s3 request to global endpoints or 'us-east-1' regional endpoints.
- v3: Deprecated. S3 client will always use regional endpoint if region is set to
us-east-1
. You can set the region toaws-global
to send requests to S3 global endpoint.
-
- v2: Whether the signature to sign requests with (overriding the API configuration) is cached.
- v3: Deprecated. SDK always caches the hashed signing keys.
-
- v2: The signature version to sign requests with (overriding the API configuration).
- v3: Deprecated. Signature V2 supported in v2 SDK has been deprecated by AWS. v3 only supports signature v4.
-
- v2: Whether SSL is enabled for requests.
- v3: Renamed to
tls
.
-
- v2: Whether to send sts request to global endpoints or regional endpoints.
- v3: Deprecated. STS client will always use regional endpoints if set to a specific region. You can set the
region to
aws-global
to send request to STS global endpoint.
-
- v2: Whether to use the Accelerate endpoint with the S3 service.
- v3: No change.
In v2, the S3 client contains an upload()
operation that supports uploading large objects with multipart upload feature offered by S3.
In v3, @aws-sdk/lib-storage
package is available.
It supports all the features offered in v2 upload()
, and supports both Node.js and browsers runtime.
In v2, the S3 client contains getSignedUrl()
and getSignedUrlPromise()
operations to generate an URL that users can use to upload or download objects from S3.
In v3, @aws-sdk/s3-request-presigner
package
is available. You don't have to differentiate getSignedUrl()
and getSignedUrlPromise()
any more. We also have a blog
discussing the details of this package.