@@ -72,31 +72,53 @@ The AWS SDK offers the following features:
72
72
To use the AWS SDK for ``MONGODB-AWS`` authentication, perform
73
73
the following steps:
74
74
75
- 1. Specify the authentication mechanism.
76
- #. Add the SDK as a dependency to your project.
77
- #. Supply your credentials by using one of the methods in the credential
78
- provider chain.
75
+ 1. :ref:`Specify the authentication mechanism <kotlin-mongodb-aws-sdk-specify>`.
76
+ #. :ref:`Add the SDK as a dependency to your project <kotlin-mongodb-aws-sdk-dependency>`.
77
+ #. :ref:`Supply your credentials by using one of the methods in the credential provider chain <kotlin-mongodb-aws-sdk-credentials>`.
79
78
80
- To specify the ``MONGODB-AWS`` authentication mechanism by using a ``MongoCredential``
81
- object, call the ``MongoCredential.createAwsCredential()`` factory method
82
- and add the ``MongoCredential`` instance to your ``MongoClient``, as shown
83
- in the following example:
79
+ .. _kotlin-mongodb-aws-sdk-specify:
84
80
85
- .. literalinclude:: /includes/security/authentication.kt
86
- :language: kotlin
87
- :dedent:
88
- :start-after: start-aws-sdk-mcred
89
- :end-before: end-aws-sdk-mcred
90
- :emphasize-lines: 1, 9
81
+ Specify the Authentication Mechanism
82
+ ````````````````````````````````````
91
83
92
- To specify the ``MONGODB-AWS`` authentication mechanism in the connection string,
93
- add it as a parameter, as shown in the following example:
84
+ You can specify the ``MONGODB-AWS`` authentication mechanism by using a connection
85
+ string or a ``MongoCredential`` object. Select the :guilabel:`Connection String`
86
+ or the :guilabel:`MongoCredential` tab below for corresponding instructions and sample code:
94
87
95
- .. literalinclude:: /includes/security/authentication.kt
96
- :language: kotlin
97
- :dedent:
98
- :start-after: start-aws-sdk-cred-string
99
- :end-before: end-aws-sdk-cred-string
88
+ .. tabs::
89
+
90
+ .. tab::
91
+ :tabid: Connection String
92
+
93
+ To specify the ``MONGODB-AWS`` authentication mechanism in the connection string,
94
+ set the ``authMechanism`` parameter to ``MONGODB-AWS``, as shown in the following
95
+ example:
96
+
97
+ .. literalinclude:: /includes/security/authentication.kt
98
+ :language: kotlin
99
+ :dedent:
100
+ :start-after: start-aws-sdk-cred-string
101
+ :end-before: end-aws-sdk-cred-string
102
+
103
+ .. tab::
104
+ :tabid: MongoCredential
105
+
106
+ To specify the ``MONGODB-AWS`` authentication mechanism by using a ``MongoCredential``
107
+ object, call the ``MongoCredential.createAwsCredential()`` factory method
108
+ and add the ``MongoCredential`` instance to your ``MongoClient``, as shown
109
+ in the following example:
110
+
111
+ .. literalinclude:: /includes/security/authentication.kt
112
+ :language: kotlin
113
+ :dedent:
114
+ :start-after: start-aws-sdk-mcred
115
+ :end-before: end-aws-sdk-mcred
116
+ :emphasize-lines: 1, 9
117
+
118
+ .. _kotlin-mongodb-aws-sdk-dependency:
119
+
120
+ Add the AWS SDK Dependency
121
+ ``````````````````````````
100
122
101
123
To add the AWS SDK as a dependency to your project, see the following
102
124
AWS documentation for the version you need:
@@ -114,6 +136,11 @@ AWS documentation for the version you need:
114
136
For the AWS SDK for Java v1, the Java driver currently tests by using the
115
137
``com.amazonaws:aws-java-sdk-core:1.12.782`` dependency.
116
138
139
+ .. _kotlin-mongodb-aws-sdk-credentials:
140
+
141
+ Supply Your Credentials
142
+ ```````````````````````
143
+
117
144
To supply your credentials, see the following AWS documentation for the
118
145
version you need:
119
146
@@ -150,8 +177,13 @@ appropriate environment variables.
150
177
To use the environment variables to supply your credentials, perform
151
178
the following steps:
152
179
153
- 1. Specify the authentication mechanism.
154
- #. Add the appropriate environment variables.
180
+ 1. :ref:`Specify the authentication mechanism <kotlin-mongodb-aws-env-specify>`.
181
+ #. :ref:`Add the appropriate environment variables <kotlin-mongodb-aws-env-set-vars>`.
182
+
183
+ .. _kotlin-mongodb-aws-env-specify:
184
+
185
+ Specify the Authentication Mechanism
186
+ ````````````````````````````````````
155
187
156
188
You can specify the ``MONGODB-AWS`` authentication mechanism by using a
157
189
``MongoCredential`` object or in the connection string.
@@ -177,7 +209,12 @@ string, add it as a parameter as shown in the following example:
177
209
:start-after: start-aws-env-cred-string
178
210
:end-before: end-aws-env-cred-string
179
211
180
- The next examples show how to provide your credentials by setting environment
212
+ .. _kotlin-mongodb-aws-env-set-vars:
213
+
214
+ Set Environment Variables
215
+ `````````````````````````
216
+
217
+ This section shows how to provide your credentials by setting environment
181
218
variables for the following types of authentication:
182
219
183
220
- Programmatic access keys
@@ -204,9 +241,9 @@ a similar shell, as shown in the following example:
204
241
205
242
export AWS_CONTAINER_CREDENTIALS_RELATIVE_URI=<your ECS endpoint>
206
243
207
- To authenticate by using **EC2 container credentials**, make sure none of the
208
- aforementioned environment variables are set . The driver obtains the
209
- credentials from the default IPv4 EC2 instance metadata endpoint.
244
+ To authenticate by using **EC2 container credentials**, do not set
245
+ the AWS environment variables. The driver obtains the credentials
246
+ from the default IPv4 EC2 instance metadata endpoint.
210
247
211
248
.. _kotlin-mongodb-aws-mongoclient-configuration:
212
249
@@ -219,10 +256,12 @@ for ``MONGODB-AWS`` authentication, call the
219
256
`createAwsCredential() <{+core-api+}/MongoCredential.html#createAwsCredential(java.lang.String,char%5B%5D)>`__
220
257
factory method.
221
258
222
- You can supply only programmatic access keys to the
223
- ``MongoCredential.createAwsCredential()`` method. If you need to supply ECS
224
- or EC2 container credentials, follow the instructions in
225
- :ref:`<kotlin-mongodb-aws-env-variables>` or :ref:`<kotlin-mongodb-aws-sdk>`.
259
+ .. tip::
260
+
261
+ You can supply only programmatic access keys to the
262
+ ``MongoCredential.createAwsCredential()`` method. If you need to supply ECS
263
+ or EC2 container credentials, follow the instructions in
264
+ :ref:`<kotlin-mongodb-aws-env-variables>`.
226
265
227
266
To use a ``MongoCredential`` object for ``MONGODB-AWS`` authentication, perform
228
267
the following steps:
@@ -242,7 +281,7 @@ in the following example:
242
281
:end-before: end-aws-mcred
243
282
:emphasize-lines: 1, 9
244
283
245
- If you need to specify an AWS session token, pass it to the
284
+ If you must specify an AWS session token, pass it to the
246
285
`withMechanismProperty() <{+core-api+}/MongoCredential.html#withMechanismProperty(java.lang.String,T)>`__
247
286
method, as shown in the following example:
248
287
0 commit comments