@@ -153,23 +153,31 @@ The driver checks for your credentials in the following sources in order:
153153 .. literalinclude:: /code-snippets/authentication/aws-env-variable.js
154154 :language: javascript
155155
156- .. important:: Retrieval of AWS Credentials
157-
158- Starting in MongoDB version 4.11, when you install the optional
159- ``aws-sdk/credential-providers`` dependency, the driver uses the AWS SDK
160- to retrieve credentials from the environment. As a result, if you
161- have a shared AWS credentials file or config file, the driver will
162- use those credentials by default.
163-
164- You can override this behavior by performing one of the following
165- actions:
166-
167- - Set ``AWS_SHARED_CREDENTIALS_FILE`` variable in your shell to point
168- to your credentials file.
169- - Set the equivalent environment variable in your application to point
170- to your credentials file.
171- - Create an AWS profile for your MongoDB credentials and set the
172- ``AWS_PROFILE`` environment variable to that profile name.
156+ Retrieving AWS Credentials
157+ --------------------------
158+
159+ When you install the optional ``aws-sdk/credential-providers`` dependency, the driver
160+ uses the AWS SDK to retrieve credentials from the environment. If you have a shared AWS
161+ credentials file or config file, the driver uses those credentials by default.
162+
163+ To manually specify the AWS credentials to retrieve, you can use the ``AWS_CREDENTIAL_PROVIDER``
164+ property to specify the credential provider. The following example passes a provider chain
165+ from the AWS SDK to the AWS authentication mechanism:
166+
167+ .. literalinclude:: /code-snippets/authentication/aws-custom-credentials.js
168+ :language: javascript
169+ :start-after: // start-custom-credentials
170+ :end-before: // end-custom-credentials
171+
172+ TO use a custom provider, you can pass any async function that returns your credentials
173+ to the ``AWS_CREDENTIAL_PROVIDER`` property. The following example shows how to pass
174+ a custom provider function that fetches credentials from environment variables to the
175+ AWS authentication mechanism:
176+
177+ .. literalinclude:: /code-snippets/authentication/aws-custom-credentials.js
178+ :language: javascript
179+ :start-after: // start-custom-credentials-function
180+ :end-before: // end-custom-credentials-function
173181
174182API Documentation
175183-----------------
0 commit comments