Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(UPGRADING): on the use of expiration in credential provider functions #5961

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ This list is indexed by [v2 config parameters](https://docs.aws.amazon.com/AWSJa
- **v3**: No change.
- [`credentials`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#credentials-property)
- **v2**: The AWS credentials to sign requests with.
- **v3**: No change. It can also be an async function that returns credentials.
- **v3**: No change. It can also be an async function that returns credentials. If the function returns an `expiration (Date)`, the function will
be called again when the expiration datetime nears.
See [v3 reference for AwsAuthInputConfig credentials](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/interfaces/_aws_sdk_middleware_signing.awsauthinputconfig-1.html#credentials).
- [`endpointCacheSize`](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#endpointCacheSize-property)
- **v2**: The size of the global cache storing endpoints from endpoint discovery operations.
Expand Down
19 changes: 14 additions & 5 deletions supplemental-docs/CLIENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,17 @@ import { fromCognitoIdentity } from "@aws-sdk/credential-providers";
const client = new S3Client({
credentials: async () => {
// get credentials from any source.
const credentials = {
/* ... */
};
return {
accessKeyId: "...",
secretAccessKey: "...",
sessionToken: "...",
accessKeyId: credentials.accessKeyId,
secretAccessKey: "etc.",
sessionToken: "etc.",
// 1. You can set an expiration near which this function will be called again.
// 2. You can use the expiration given by your upstream credentials provider, if it exists.
// 3. Omitting an expiration will result in this function not being called more than once.
expiration: new Date(),
};
},
});
Expand Down Expand Up @@ -340,11 +347,12 @@ const client = new DynamoDBClient({
requestHandler: new NodeHttpHandler({
requestTimeout: 3_000,
httpsAgent: new https.Agent({
maxSockets: 25
maxSockets: 25,
}),
}),
});
```

```ts
// Example: short form requestHandler configuration.
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
Expand All @@ -356,8 +364,9 @@ const client = new DynamoDBClient({
},
});
```

You can instead pass the constructor parameters directly. The default requestHandler for the platform and service will be used.
For Node.js, most services use `NodeHttpHandler`. For browsers, most services use `FetchHttpHandler`.
For Node.js, most services use `NodeHttpHandler`. For browsers, most services use `FetchHttpHandler`.

Kinesis, Lex Runtime v2, QBusiness, TranscribeStreaming use `NodeHttp2Handler` by default instead in Node.js.
RekognitionStreaming and TranscribeStreaming use the `WebSocketFetchHandler` by default instead in browsers.
Expand Down
Loading