You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -229,145 +228,253 @@ connect using ``MONGODB-CR``.
229
228
``MONGODB-AWS``
230
229
~~~~~~~~~~~~~~~
231
230
231
+
..
232
+
The MONGODB-AWS section structure was updated for v4.8 of the driver. Avoid
233
+
backporting any documentation that might not apply to a prior version.
234
+
232
235
.. note::
233
236
234
-
The MONGODB-AWS authentication mechanism is available in MongoDB
235
-
Atlas.
237
+
The MONGODB-AWS authentication mechanism is available for MongoDB
238
+
deployments on MongoDB Atlas.
236
239
237
240
The ``MONGODB-AWS`` authentication mechanism uses your Amazon Web Services
238
241
Identity and Access Management (AWS IAM) credentials to authenticate your
239
-
user.
242
+
user. To learn more about configuring MongoDB Atlas, see the
243
+
:atlas:`Set Up Passwordless Authentication with AWS IAM Roles </security/passwordless-authentication/#set-up-passwordless-authentication-with-aws-iam-roles>`
244
+
guide.
240
245
241
-
You can store your AWS credentials as environment variables, or insert
242
-
them inline like the examples below. The driver checks for your credentials
243
-
in the following order:
246
+
To instruct the driver to use this authentication mechanism, you can specify
247
+
``MONGODB-AWS`` either as a parameter in the connection string or by using
248
+
the ``MongoCredential.createAwsCredential()`` factory method.
244
249
245
-
1. Supplied values in a ``MongoCredential`` object or the provided connection string.
246
-
2. Your environment variables. (``AWS_ACCESS_KEY_ID``, ``AWS_SECRET_ACCESS_KEY``,
247
-
and optionally ``AWS_SESSION_TOKEN``)
248
-
3. The AWS EC2 endpoint specified in the ``AWS_CONTAINER_CREDENTIALS_RELATIVE_URI``
249
-
environment variable.
250
-
4. The default AWS EC2 endpoint. For more information, see `IAM Roles for Tasks
To supply your credentials, see the following AWS documentation for the
327
+
version you need:
328
+
329
+
- To learn more about the **AWS SDK for Java v2** class the driver uses to
330
+
get the credentials, see the `DefaultCredentialsProvider <https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/auth/credentials/DefaultCredentialsProvider.html>`__
331
+
API documentation.
332
+
333
+
Learn how to supply your credentials to this class from the
334
+
`Use the default credential provider chain <https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/credentials.html#credentials-chain>`__
335
+
section.
336
+
337
+
- To learn more about the **AWS SDK for Java v1** class the driver uses to
338
+
get the credentials, see the `DefaultAWSCredentialsProviderChain <https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html>`__
339
+
API documentation.
340
+
341
+
Learn how to supply your credentials to this class from the
342
+
`Using the Default Credential Provider Chain <https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html#credentials-default>`__
To authenticate using **EC2 container credentials**, make sure none of the
417
+
aforementioned environment variables are set. The driver obtains the
418
+
credentials from the default IPv4 EC2 instance metadata endpoint.
353
419
354
-
In your client execution environment, set an environment variable
355
-
called ``AWS_SESSION_TOKEN`` and assign your token to it. The value is
356
-
automatically picked up by your ``MongoClient`` when you specify the
357
-
``MONGODB-AWS`` authentication mechanism.
420
+
.. _java-mongodb-aws-mongoclient-configuration:
358
421
359
-
Refresh Credentials
360
-
+++++++++++++++++++
422
+
Specify Your Credentials in a MongoCredential
423
+
+++++++++++++++++++++++++++++++++++++++++++++
361
424
362
-
The driver supports refreshing credentials for cases such as assuming roles
363
-
or using `Elastic Kubernetes Service <https://docs.aws.amazon.com/eks/latest/userguide/what-is-eks.html>`__.
425
+
You can supply your AWS IAM credentials to a ``MongoClient`` by using a
426
+
a ``MongoCredential`` instance. To construct the ``MongoCredential`` instance
427
+
for ``MONGODB-AWS`` authentication, use the `createAwsCredential() <{+api+}/apidocs/mongodb-driver-core/com/mongodb/MongoCredential.html#createAwsCredential(java.lang.String,char%5B%5D)>`__
428
+
factory method.
429
+
430
+
You can supply only programmatic access keys to the
431
+
``MongoCredential.createAwsCredential()`` method. If you need to supply ECS
432
+
or EC2 container credentials, use the instructions in
433
+
:ref:`<java-mongodb-aws-env-variables>` or :ref:`<java-mongodb-aws-sdk>`.
434
+
435
+
To use the the ``MongoCredential`` for ``MONGODB-AWS`` authentication, you
436
+
must perform the following:
437
+
438
+
1. Specify the authentication mechanism
439
+
#. Supply the credentials
440
+
441
+
To specify the authentication mechanism by using a ``MongoCredential``,
442
+
use the ``MongoCredential.createAwsCredential()`` factory method
443
+
and add the ``MongoCredential`` instance to your ``MongoClient`` as shown
0 commit comments