@@ -10,11 +10,52 @@ content: |
10
10
- **access key ID**
11
11
- **secret access key**
12
12
13
- 2. Grant the IAM user full ``List`` and ``Read`` permissions for the KMS
13
+ 2. Grant the IAM user narrowly scoped ``List`` and ``Read`` permissions only for the KMS
14
14
service. See Amazon's official documentation on
15
15
`Adding permissions to a user <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_change-permissions.html>`__
16
16
to set these permissions.
17
17
18
+ .. important:: Authenticate with IAM Roles in Production
19
+
20
+ When deploying your CSFLE-enabled application to a production environment,
21
+ authenticate your application through an IAM role instead of an IAM user.
22
+
23
+ To authenticate with an IAM role, specify your temporary IAM role credentials
24
+ in your KMS provider object as follows:
25
+
26
+ .. code-block:: json
27
+
28
+ {
29
+ "accessKeyId":"<temporary access key ID>",
30
+ "secretAccessKey":"<temporary secret access key>",
31
+ "sessionToken":"<temporary session token>"
32
+ }
33
+
34
+ You can get your temporary IAM role credentials through the following mechanisms:
35
+
36
+ - `Call AssumeRole <https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html>`__
37
+ - `Retrieve Credentials from EC2 Instance Metadata <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#instance-metadata-security-credentials>`__
38
+
39
+ Your application must include logic to get new temporary credentials
40
+ and recreate your CSFLE-enabled ``MongoClient`` instance when each set of
41
+ temporary credentials expires.
42
+
43
+ To learn more about IAM roles, see the following resources from AWS:
44
+
45
+ - `IAM roles <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html>`__
46
+ - `When to create an IAM role (instead of a user) <https://docs.aws.amazon.com/IAM/latest/UserGuide/id.html#id_which-to-choose_role>`__
47
+
48
+ To learn how to get temporary credentials and assume a role in each of
49
+ the languages supported in this guide, see the following ``AssumeRole``
50
+ runnable examples from AWS:
51
+
52
+ - `Java <https://docs.aws.amazon.com/code-samples/latest/catalog/javav2-sts-src-main-java-com-example-sts-AssumeRole.java.html>`__
53
+ - `NodeJS <https://docs.aws.amazon.com/code-samples/latest/catalog/javascriptv3-sts-src-sts_assumerole.js.html>`__
54
+ - `Python <https://docs.aws.amazon.com/code-samples/latest/catalog/python-sts-sts_temporary_credentials-assume_role_mfa.py.html>`__
55
+ (example uses multi-factor authentication)
56
+ - `C# <https://docs.aws.amazon.com/code-samples/latest/catalog/dotnetv3-STS-AssumeRole-AssumeRoleExample-AssumeRole.cs.html>`__
57
+ - `Go <https://docs.aws.amazon.com/code-samples/latest/catalog/go-sts-TakeRole-TakeRole.go.html>`__
58
+
18
59
---
19
60
title : Create the Master Key
20
61
ref : create-the-master-key
@@ -58,19 +99,28 @@ content: |
58
99
.. list-table::
59
100
:header-rows: 1
60
101
:stub-columns: 1
61
- :widths: 30 15 45
102
+ :widths: 25 15 15 45
62
103
63
104
* - Field
64
- - Required
105
+ - Required for IAM User
106
+ - Required for IAM Role
65
107
- Description
66
108
67
109
* - Access Key ID
68
110
- Yes
69
- - Identifies the account user
111
+ - Yes
112
+ - Identifies the account user.
70
113
71
114
* - Secret Access Key
72
115
- Yes
73
- - Contains the authentication credentials of the account user
116
+ - Yes
117
+ - Contains the authentication credentials of the account user.
118
+
119
+ * - Session Token
120
+ - No
121
+ - Yes
122
+ - Contains a token obtained from AWS Security Token Service (STS).
123
+
74
124
75
125
2. Next, add your authentication credentials to your CSFLE-enabled client
76
126
code:
@@ -158,7 +208,6 @@ content: |
158
208
return map[string]map[string]interface{}{"aws": structs.Map(a.credentials)}
159
209
}
160
210
161
-
162
211
---
163
212
title : Create a New Data Encryption Key
164
213
ref : create-a-new-data-key
0 commit comments