@@ -128,14 +128,14 @@ in the following sample code.
128128---------------
129129
130130.. note::
131- The MONGODB-AWS authentication mechanism is only available in MongoDB
131+ The MONGODB-AWS authentication mechanism is available only in MongoDB
132132 versions 4.4 and later.
133133
134134The ``MONGODB-AWS`` authentication mechanism uses your Amazon Web Services
135135Identity and Access Management (AWS IAM) credentials to authenticate your
136136user. If you do not already have the `AWS signature library
137- <https://www.npmjs.com/package/aws4>`__, install it using the following
138- ``npm`` command:
137+ <https://www.npmjs.com/package/aws4>`__, use the following
138+ ``npm`` command to install it :
139139
140140.. code-block:: bash
141141
@@ -147,9 +147,10 @@ enabled, specify the ``MONGODB-AWS`` authentication mechanism.
147147The driver checks for your credentials in the following sources in order:
148148
1491491. Connection string
150- 2. Environment variables
151- 3. AWS ECS endpoint specified in ``AWS_CONTAINER_CREDENTIALS_RELATIVE_URI``
152- 4. AWS EC2 endpoint. For more information, see `IAM Roles for Tasks
150+ #. Environment variables
151+ #. Web identity token file
152+ #. AWS ECS endpoint specified in ``AWS_CONTAINER_CREDENTIALS_RELATIVE_URI``
153+ #. AWS EC2 endpoint. For more information, see `IAM Roles for Tasks
153154 <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html>`_.
154155
155156.. important::
@@ -161,27 +162,6 @@ The driver checks for your credentials in the following sources in order:
161162
162163.. tabs::
163164
164- .. tab:: Environment Variables
165- :tabid: environment variables
166-
167- To authenticate to your MongoDB instance using AWS credentials stored in
168- environment variables, you must specify the following items:
169-
170- - In your connection string, specify the ``MONGODB-AWS`` authentication
171- mechanism as the value of the ``authMechanism`` parameter.
172- - In your ``AWS_ACCESS_KEY_ID`` environment variable, specify the value
173- of your AWS access key ID.
174- - In your ``AWS_SECRET_ACCESS_KEY`` environment variable, specify the
175- value of your AWS secret access key.
176- - If your login requires an AWS session token, specify the value in
177- your ``AWS_SESSION_TOKEN`` environment variable.
178-
179- The following code shows an example of specifying the ``MONGODB-AWS``
180- authentication mechanism with environment variables:
181-
182- .. literalinclude:: /code-snippets/authentication/aws-env-variable.js
183- :language: javascript
184-
185165 .. tab:: Connection String
186166 :tabid: connection string
187167
@@ -201,6 +181,49 @@ The driver checks for your credentials in the following sources in order:
201181 .. literalinclude:: /code-snippets/authentication/aws.js
202182 :language: javascript
203183
184+ .. tab:: Environment Variables
185+ :tabid: environment variables
186+
187+ To authenticate to your MongoDB instance using AWS credentials stored in
188+ environment variables, set the following variables by using
189+ a shell:
190+
191+ .. code-block:: bash
192+
193+ export AWS_ACCESS_KEY_ID=<awsKeyId>
194+ export AWS_SECRET_ACCESS_KEY=<awsSecretKey>
195+ export AWS_SESSION_TOKEN=<awsSessionToken>
196+
197+ .. note::
198+
199+ Omit the line containing ``AWS_SESSION_TOKEN`` if you don't need an AWS
200+ session token for that role.
201+
202+ After you've set the preceding environment variables, specify the ``MONGODB-AWS``
203+ authentication mechanism in your connection string as shown in the following example:
204+
205+ .. literalinclude:: /code-snippets/authentication/aws-env-variable.js
206+ :language: javascript
207+
208+ .. tab:: Web Identity Token File
209+ :tabid: web-identity-token-file
210+
211+ You can use the OpenID Connect (OIDC) token obtained from a web identity provider to authenticate
212+ to Amazon Elastic Kubernetes Service (EKS) or other services.
213+ To use an OIDC token, create a file that contains your token, then
214+ set the absolute path to this file in an environment variable by using
215+ a shell as shown in the following example:
216+
217+ .. code-block:: bash
218+
219+ export AWS_WEB_IDENTITY_TOKEN_FILE=<absolute path to file containing your OIDC token>
220+
221+ After you've set the preceding environment variable, specify the ``MONGODB-AWS``
222+ authentication mechanism in your connection string as shown in the following example:
223+
224+ .. literalinclude:: /code-snippets/authentication/aws-env-variable.js
225+ :language: javascript
226+
204227``X.509``
205228---------
206229
0 commit comments