Skip to content

Commit 8e846a7

Browse files
AllanZhengYPtrivikr
authored andcommitted
docs: add v2 to v3 API changes to UPGRADING.md (#2106)
* docs: add v2 to v3 changes note * docs: address feedbacks * docs(readme): fix upgrade link Co-authored-by: Trivikram Kamat <[email protected]>
1 parent 2cf9852 commit 8e846a7

File tree

2 files changed

+207
-0
lines changed

2 files changed

+207
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ In the above example, we’re adding a middleware to our DynamoDB client’s mid
133133
The first argument is a function that accepts next, the next middleware in the stack to call, and context, an object that contains some information about the operation being called.
134134
It returns a function that accepts args, an object that contains the parameters passed to the operation and the request, and returns the result from calling the next middleware with args.
135135

136+
#### Other Changes
137+
138+
If you are looking for a breakdown of the API changes from AWS SDK for JavaScript v2 to v3,
139+
we have them listed in [UPGRADING.md](https://github.com/aws/aws-sdk-js-v3/blob/main/UPGRADING.md).
140+
136141
### Install from Source
137142

138143
All clients have been published to NPM and can be installed as described above. If you want to play with latest clients, you can build from source as follows:

UPGRADING.md

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# Upgrading Notes (2.x to 3.x)
2+
3+
This document captures notable changes from AWS SDK for JavaScript v2 to v3.
4+
The v3 is also known as modular AWS SDK for JavaScript.
5+
6+
Because v3 is a modular rewrite of v2, some basic conceptions are different between v2 and v3. You can learn about
7+
these changes in our [blog posts](https://aws.amazon.com/blogs/developer/category/developer-tools/aws-sdk-for-javascript-in-node-js/).
8+
The following blog posts will get you up to speed:
9+
10+
- [Modular packages in AWS SDK for JavaScript](https://aws.amazon.com/blogs/developer/modular-packages-in-aws-sdk-for-javascript/)
11+
- [Introducing Middleware Stack in Modular AWS SDK for JavaScript](https://aws.amazon.com/blogs/developer/first-class-typescript-support-in-modular-aws-sdk-for-javascript/)
12+
13+
The summary of interface changes from AWS SDK for JavaScript v2 to v3 is given below.
14+
The goal is to help you easily find the v3 equivalents of the v2 APIs you are already familiar with.
15+
16+
## Client Constructors
17+
18+
This list is indexed by [v2 config parameters](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html). For
19+
options shown as `Planned` in v3, they will be supported but no timeline can be shared at the moment. They
20+
might not have the same name either.
21+
22+
- [`computeChecksums`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#computeChecksums-property)
23+
- **v2**: Whether to compute MD5 checksums for payload bodies when the service accepts it (currently supported in S3
24+
only).
25+
- **v3**: Not available. Planned.
26+
- [`convertResponseTypes`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#convertResponseTypes-property)
27+
- **v2**: Whether types are converted when parsing response data.
28+
- **v3**: **Deprecated**. This option is considered not type-safe because it doesn't convert the types like time stamp
29+
or base64 binaries from the JSON response.
30+
- [`correctClockSkew`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#correctClockSkew-property)
31+
- **v2**: Whether to apply a clock skew correction and retry requests that fail because of an skewed client
32+
clock.
33+
- **v3**: **Deprecated**. SDK _always_ applies a clock skew correction.
34+
- [`systemClockOffset`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#systemClockOffset-property)
35+
- **v2**: An offset value in milliseconds to apply to all signing times.
36+
- **v3**: No change.
37+
- [`credentials`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#credentials-property)
38+
- **v2**: The AWS credentials to sign requests with.
39+
- **v3**: No change. It can also be an async function that returns credentials.
40+
See [v3 reference for AwsAuthInputConfig credentials](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/interfaces/_aws_sdk_middleware_signing.awsauthinputconfig-1.html#credentials).
41+
- [`endpointCacheSize`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#endpointCacheSize-property)
42+
- **v2**: The size of the global cache storing endpoints from endpoint discovery operations.
43+
- **v3**: Not available. Planned. This option configures endpoint discovery behavior, which is not yet available in v3.
44+
- [`endpointDiscoveryEnabled`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#endpointDiscoveryEnabled-property)
45+
- **v2**: Whether to call operations with endpoints given by service dynamically.
46+
- **v3**: Not available. Planned. This option configures endpoint discovery behavior, which is not yet available in v3.
47+
- [`hostPrefixEnabled`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#hostPrefixEnabled-property)
48+
- **v2**: Whether to marshal request parameters to the prefix of hostname.
49+
- **v3**: **Deprecated**. SDK _always_ injects the hostname prefix when necessary.
50+
- [`httpOptions`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#httpOptions-property)
51+
52+
A set of options to pass to the low-level HTTP request. These options are aggregated differently in v3. You can
53+
configure them by supplying a new `requestHandler`. Here's the example of setting http options in Node.js runtime. You
54+
can find more in [v3 reference for NodeHttpHandler](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/classes/_aws_sdk_node_http_handler.nodehttphandler-1.html).
55+
56+
All v3 requests use HTTPS by default. You only need to provide custom httpsAgent.
57+
58+
```javascript
59+
const { Agent } = require("https");
60+
const { Agent: HttpAgnet } = require("http");
61+
const { NodeHttpHandler } = require("@aws-sdk/node-http-handler");
62+
const dynamodbClient = new DynamoDBClient({
63+
requestHandler: new NodeHttpHandler({
64+
httpsAgent: new Agent({
65+
/*params*/
66+
}),
67+
connectionTimeout: /*number in milliseconds*/
68+
socketTimeout: /*number in milliseconds*/
69+
}),
70+
});
71+
```
72+
73+
If you are passing custom endpoint which uses http, then you need to provide httpAgent.
74+
75+
```javascript
76+
const { Agent } = require("http");
77+
const { NodeHttpHandler } = require("@aws-sdk/node-http-handler");
78+
79+
const dynamodbClient = new DynamoDBClient({
80+
requestHandler: new NodeHttpHandler({
81+
httpAgent: new Agent({
82+
/*params*/
83+
}),
84+
}),
85+
endpoint: "http://example.com",
86+
});
87+
```
88+
89+
If the client is running in browsers, a different set of options is available. You can find more in [v3
90+
reference for FetchHttpHandler](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/classes/_aws_sdk_fetch_http_handler.fetchhttphandler-1.html).
91+
92+
```javascript
93+
const { FetchHttpHandler } = require("@aws-sdk/fetch-http-handler");
94+
const dynamodbClient = new DynamoDBClient({
95+
requestHandler: new FetchHttpHandler({
96+
requestTimeout: /*number in milliseconds*/
97+
}),
98+
});
99+
```
100+
101+
Each option of `httpOptions` is specified below:
102+
103+
- `proxy`
104+
- **v2**: The URL to proxy requests through
105+
- **v3**: You can set up a proxy with an agent following [Configuring proxies for Node.js](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-proxies.html)
106+
- `agent`
107+
108+
- **v2**: The Agent object to perform HTTP requests with. Used for connection pooling.
109+
- **v3**: You can configure `httpAgent` or `httpsAgent` as shown in the examples above.
110+
111+
- `connectionTimeout`
112+
- **v2**: Sets the socket to timeout after failing to establish a connection with the server after connectTimeout
113+
milliseconds.
114+
- **v3**: `connectionTimeout` is available [in `NodeHttpHandler` options](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/classes/_aws_sdk_node_http_handler.nodehttphandler-1.html).
115+
- `timeout`
116+
- **v2**: The number of milliseconds a request can take before automatically being terminated.
117+
- **v3**: Hard request timeout is not available in `NodeHttpHandler`, but available as `requestTimeout` [in
118+
`FetchHttphandler` in browsers](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/classes/_aws_sdk_fetch_http_handler.fetchhttphandler-1.html)
119+
- `xhrAsync`
120+
- **v2**: Whether the SDK will send asynchronous HTTP requests.
121+
- **v3**: **Deprecated**. Requests are _always_ asynchronous.
122+
- `xhrWithCredentials`
123+
- **v2**: Sets the "withCredentials" property of an XMLHttpRequest object.
124+
- **v3**: Not available. SDK inherits [the default fetch configurations](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)
125+
126+
- [`logger`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#logger-property)
127+
- **v2**: An object that responds to .write() (like a stream) or .log() (like the console object) in order to log information about requests.
128+
- **v3**: No change. More granular logs are available in v3.
129+
- [`maxRedirects`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#maxRedirects-property)
130+
- **v2**: The maximum amount of redirects to follow for a service request.
131+
- **v3**: **Deprecated**. SDK _does not_ follow redirects to avoid unintentional cross-region requests.
132+
- [`maxRetries`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#maxRetries-property)
133+
- **v2**: The maximum amount of retries to perform for a service request.
134+
- **v3**: Changed to `maxAttempts`. See more in [v3 reference for RetryInputConfig](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/interfaces/_aws_sdk_middleware_retry.retryinputconfig-2.html#maxattempts).
135+
Note that the `maxAttempt` should be `maxRetries + 1`.
136+
- [`paramValidation`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#paramValidation-property)
137+
- **v2**: Whether input parameters should be validated against the operation description before sending the request.
138+
- **v3**: **Deprecated**. SDK _does not_ do validation on client-side at runtime.
139+
- [`region`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#region-property)
140+
- **v2**: The region to send service requests to.
141+
- **v3**: No change. It can also be an async function that returns a region string.
142+
- [`retryDelayOptions`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#retryDelayOptions-property)
143+
- **v2**: A set of options to configure the retry delay on retryable errors.
144+
- **v3**: **Deprecated**. SDK supports more flexible retry strategy with `retryStrategy` client constructor option. See
145+
more [in v3 reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/interfaces/_aws_sdk_types.retrystrategy-1.html)
146+
- [`s3BucketEndpoint`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#s3BucketEndpoint-property)
147+
- **v2**: Whether the provided endpoint addresses an individual bucket (false if it addresses the root API endpoint).
148+
- **v3**: Renamed to `bucketEndpoint`
149+
- [`s3DisableBodySigning`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#s3DisableBodySigning-property)
150+
- **v2**: Whether to disable S3 body signing when using signature version v4.
151+
- **v3**: Renamed to `applyChecksum`
152+
- [`s3ForcePathStyle`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#s3ForcePathStyle-property)
153+
- **v2**: Whether to force path style URLs for S3 objects.
154+
- **v3**: Renamed to `forcePathStyle`
155+
- [`s3UseArnRegion`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#s3UseArnRegion-property)
156+
- **v2**: Whether to override the request region with the region inferred from requested resource's ARN.
157+
- **v3**: Renamed to `useArnRegion`
158+
- [`s3UsEast1RegionalEndpoint`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#s3UsEast1RegionalEndpoint-property)
159+
- **v2**: When region is set to 'us-east-1', whether to send s3 request to global endpoints or 'us-east-1' regional
160+
endpoints.
161+
- **v3**: **Deprecated**. S3 client will always use regional endpoint if region is set to `us-east-1`. You can set the
162+
region to `aws-global` to send requests to S3 global endpoint.
163+
- [`signatureCache`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#signatureCache-property)
164+
- **v2**: Whether the signature to sign requests with (overriding the API configuration) is cached.
165+
- **v3**: **Deprecated**. SDK _always_ caches the hashed signing keys.
166+
- [`signatureVersion`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#signatureVersion-property)
167+
- **v2**: The signature version to sign requests with (overriding the API configuration).
168+
- **v3**: **Deprecated**. Signature V2 supported in v2 SDK has been deprecated by AWS. v3 _only_ supports signature v4.
169+
- [`sslEnabled`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#sslEnabled-property)
170+
- **v2**: Whether SSL is enabled for requests.
171+
- **v3**: Renamed to `tls`.
172+
- [`stsRegionalEndpoints`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#stsRegionalEndpoints-property)
173+
- **v2**: Whether to send sts request to global endpoints or regional endpoints.
174+
- **v3**: **Deprecated**. STS client will _always_ use regional endpoints if set to a specific region. You can set the
175+
region to `aws-global` to send request to STS global endpoint.
176+
- [`useAccelerateEndpoint`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#useAccelerateEndpoint-property)
177+
- **v2**: Whether to use the Accelerate endpoint with the S3 service.
178+
- **v3**: No change.
179+
180+
## S3 Multipart Upload
181+
182+
In v2, the S3 client contains an [`upload()`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property)
183+
operation that supports uploading large objects with [multipart upload feature offered by S3](https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html).
184+
185+
In v3, [`@aws-sdk/lib-storage` package](https://github.com/aws/aws-sdk-js-v3/blob/main/lib/lib-storage) is available.
186+
It supports all the features offered in v2 `upload()`, and supports both Node.js and browsers runtime.
187+
188+
## S3 Presigned URL
189+
190+
In v2, the S3 client contains [`getSignedUrl()`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getSignedUrl-property)
191+
and [`getSignedUrlPromise()`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#getSignedUrlPromise-property)
192+
operations to generate an URL that users can use to upload or download objects from S3.
193+
194+
In v3, [`@aws-sdk/s3-request-presigner` package](https://github.com/aws/aws-sdk-js-v3/tree/main/packages/s3-request-presigner)
195+
is available. You don't have to differentiate `getSignedUrl()` and `getSignedUrlPromise()` any more. We also have [a blog](https://aws.amazon.com/blogs/developer/generate-presigned-url-modular-aws-sdk-javascript/)
196+
discussing the details of this package.
197+
198+
<!---
199+
## DynamoDB Document Client
200+
201+
TBD
202+
-->

0 commit comments

Comments
 (0)