Skip to content

Commit c094d90

Browse files
authored
docs(credential-providers): doc update for credentials (#7464)
* docs(credential-providers): doc update for credentials * docs: grammar
1 parent 2c77b1f commit c094d90

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

packages/credential-providers/README.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ An `AwsCredentialIdentityProvider` is any function that matches the signature:
6262
}>;
6363
```
6464

65+
That is, an async function which returns an object containing AWS credentials.
66+
67+
Whether you write your own such function or use one of the providers from this package, when used in
68+
conjunction with an AWS SDK Client, the client will cache the resulting credentials
69+
until there is less than 5 minutes remaining to their expiration, at which point the
70+
function will be called again, and the new credentials cached.
71+
72+
This is designed to minimize the number of credential requests. Each client
73+
instance has a separate cache of credentials, so if you want to share credential caching
74+
between clients, you'll need to implement your own cache outside the SDK.
75+
6576
#### Outer and inner clients
6677

6778
A "parent/outer/upper/caller" (position), or "data" (purpose) client refers
@@ -165,7 +176,6 @@ for more information.
165176

166177
```javascript
167178
import { fromCognitoIdentity } from "@aws-sdk/credential-providers"; // ES6 import
168-
// const { fromCognitoIdentity } = require("@aws-sdk/credential-providers"); // CommonJS import
169179

170180
const client = new FooClient({
171181
region,
@@ -207,7 +217,6 @@ Results from `GetId` are cached internally, but results from `GetCredentialsForI
207217

208218
```javascript
209219
import { fromCognitoIdentityPool } from "@aws-sdk/credential-providers"; // ES6 import
210-
// const { fromCognitoIdentityPool } = require("@aws-sdk/credential-providers"); // CommonJS import
211220

212221
const client = new FooClient({
213222
region,
@@ -252,7 +261,6 @@ credentials from [STS AssumeRole API][assumerole_api].
252261

253262
```javascript
254263
import { fromTemporaryCredentials } from "@aws-sdk/credential-providers"; // ES6 import
255-
// const { fromTemporaryCredentials } = require("@aws-sdk/credential-providers"); // CommonJS import
256264

257265
const client = new FooClient({
258266
region,
@@ -291,12 +299,11 @@ const client = new FooClient({
291299
- Uses `@aws-sdk/client-sts`
292300
- Available in browsers & native apps
293301

294-
The function `fromWebToken` returns `AwsCredentialIdentityProvider` that gets credentials calling
302+
The function `fromWebToken` returns an `AwsCredentialIdentityProvider` that gets credentials calling
295303
[STS AssumeRoleWithWebIdentity API][assumerolewithwebidentity_api]
296304

297305
```javascript
298306
import { fromWebToken } from "@aws-sdk/credential-providers"; // ES6 import
299-
// const { fromWebToken } = require("@aws-sdk/credential-providers"); // CommonJS import
300307

301308
const client = new FooClient({
302309
region,
@@ -366,7 +373,6 @@ read from the ECS container metadata service and the EC2 instance metadata servi
366373

367374
```javascript
368375
import { fromInstanceMetadata } from "@aws-sdk/credential-providers"; // ES6 import
369-
// const { fromInstanceMetadata } = require("@aws-sdk/credential-providers"); // CommonJS import
370376

371377
const client = new FooClient({
372378
credentials: fromInstanceMetadata({
@@ -382,7 +388,6 @@ const client = new FooClient({
382388

383389
```javascript
384390
import { fromContainerMetadata } from "@aws-sdk/credential-providers"; // ES6 import
385-
// const { fromContainerMetadata } = require("@aws-sdk/credential-providers"); // CommonJS import
386391

387392
const client = new FooClient({
388393
credentials: fromContainerMetadata({
@@ -396,12 +401,12 @@ const client = new FooClient({
396401
});
397402
```
398403

399-
A `AwsCredentialIdentityProvider` function created with `fromContainerMetadata` will return a promise that will
404+
An `AwsCredentialIdentityProvider` function created with `fromContainerMetadata` will return a promise that will
400405
resolve with credentials for the IAM role associated with containers in an Amazon ECS task. Please
401406
see [IAM Roles for Tasks][iam_roles_for_tasks] for more information on using IAM roles with Amazon
402407
ECS.
403408

404-
A `AwsCredentialIdentityProvider` function created with `fromInstanceMetadata` will return a promise that will
409+
An `AwsCredentialIdentityProvider` function created with `fromInstanceMetadata` will return a promise that will
405410
resolve with credentials for the IAM role associated with an EC2 instance.
406411
Please see [IAM Roles for Amazon EC2][iam_roles_for_ec2] for more information on using IAM roles
407412
with Amazon EC2. Both IMDSv1 (a request/response method) and IMDSv2 (a session-oriented method) are
@@ -443,7 +448,6 @@ Node.js:
443448

444449
```js
445450
import { fromHttp } from "@aws-sdk/credential-providers";
446-
// const { fromHttp } = require("@aws-sdk/credential-providers");
447451

448452
const client = new FooClient({
449453
credentials: fromHttp({
@@ -528,7 +532,6 @@ credentials file will be given precedence over the profile found in the config f
528532

529533
```javascript
530534
import { fromIni } from "@aws-sdk/credential-providers"; // ES6 import
531-
// const { fromIni } = require("@aws-sdk/credential-providers"); // CommonJS import
532535

533536
const client = new FooClient({
534537
// As of v3.714.0, an easy way to select a profile is to set it on the client.
@@ -671,14 +674,13 @@ See [`fromSSO()`](#fromsso) for more information
671674

672675
```javascript
673676
import { fromEnv } from "@aws-sdk/credential-providers"; // ES6 import
674-
// const { fromEnv } = require("@aws-sdk/credential-providers"); // CommonJS import
675677

676678
const client = new FooClient({
677679
credentials: fromEnv(),
678680
});
679681
```
680682

681-
`fromEnv` returns a `AwsCredentialIdentityProvider` function, that reads credentials from the following
683+
`fromEnv` returns an `AwsCredentialIdentityProvider` function, that reads credentials from the following
682684
environment variables:
683685

684686
- `AWS_ACCESS_KEY_ID` - The access key for your AWS account.
@@ -698,7 +700,6 @@ contains a falsy value, the promise returned by the `fromEnv` function will be r
698700

699701
```javascript
700702
import { fromProcess } from "@aws-sdk/credential-providers"; // ES6 import
701-
// const { fromProcess } = require("@aws-sdk/credential-providers"); // CommonJS import
702703

703704
const client = new FooClient({
704705
// Optional, available on clients as of v3.714.0.
@@ -721,7 +722,7 @@ const client = new FooClient({
721722
});
722723
```
723724

724-
`fromSharedConfigFiles` creates a `AwsCredentialIdentityProvider` functions that executes a given process and
725+
`fromProcess` creates an `AwsCredentialIdentityProvider` functions that executes a given process and
725726
attempt to read its standard output to receive a JSON payload containing the credentials. The
726727
process command is read from a shared credentials file at `~/.aws/credentials` and a shared
727728
configuration file at `~/.aws/config`. Both files are expected to be INI formatted with section
@@ -780,16 +781,15 @@ The function `fromTokenFile` returns `AwsCredentialIdentityProvider` that reads
780781

781782
```javascript
782783
import { fromTokenFile } from "@aws-sdk/credential-providers"; // ES6 import
783-
// const { fromTokenFile } = require("@aws-sdk/credential-providers"); // CommonJS import
784784

785785
const client = new FooClient({
786786
region: "us-west-2",
787787
credentials: fromTokenFile({
788788
// Optional overrides. This is passed to an inner STS client
789789
// instantiated to resolve the credentials. Region is inherited
790790
// from the upper client if present unless overridden.
791-
clientConfig: {}
792-
});
791+
clientConfig: {},
792+
}),
793793
});
794794
```
795795

@@ -821,7 +821,6 @@ function. You can either load the SSO config from shared INI credential files, o
821821

822822
```javascript
823823
import { fromSSO } from "@aws-sdk/credential-providers"; // ES6 import
824-
// const { fromSSO } = require("@aws-sdk/credential-providers") // CommonJS import
825824

826825
const client = new FooClient({
827826
// Optional, available on clients as of v3.714.0.
@@ -950,7 +949,7 @@ messages be sent to the Instance Metadata Service
950949

951950
```js
952951
import { fromNodeProviderChain } from "@aws-sdk/credential-providers"; // ES6 import
953-
// const { fromNodeProviderChain } = require("@aws-sdk/credential-providers") // CommonJS import
952+
954953
const credentialProvider = fromNodeProviderChain({
955954
// This provider accepts any input of fromEnv(), fromSSO(), fromTokenFile(),
956955
// fromIni(), fromProcess(), fromInstanceMetadata(), fromContainerMetadata()

0 commit comments

Comments
 (0)