Skip to content

Commit 4fe3b4c

Browse files
(DOCSP-19842) CSFLE IAM Role (#801)
1 parent 0bc2901 commit 4fe3b4c

File tree

1 file changed

+55
-6
lines changed

1 file changed

+55
-6
lines changed

source/includes/steps-fle-convert-to-a-remote-master-key-aws.yaml

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,52 @@ content: |
1010
- **access key ID**
1111
- **secret access key**
1212
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
1414
service. See Amazon's official documentation on
1515
`Adding permissions to a user <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_change-permissions.html>`__
1616
to set these permissions.
1717
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+
1859
---
1960
title: Create the Master Key
2061
ref: create-the-master-key
@@ -58,19 +99,28 @@ content: |
5899
.. list-table::
59100
:header-rows: 1
60101
:stub-columns: 1
61-
:widths: 30 15 45
102+
:widths: 25 15 15 45
62103
63104
* - Field
64-
- Required
105+
- Required for IAM User
106+
- Required for IAM Role
65107
- Description
66108
67109
* - Access Key ID
68110
- Yes
69-
- Identifies the account user
111+
- Yes
112+
- Identifies the account user.
70113
71114
* - Secret Access Key
72115
- 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+
74124
75125
2. Next, add your authentication credentials to your CSFLE-enabled client
76126
code:
@@ -158,7 +208,6 @@ content: |
158208
return map[string]map[string]interface{}{"aws": structs.Map(a.credentials)}
159209
}
160210
161-
162211
---
163212
title: Create a New Data Encryption Key
164213
ref: create-a-new-data-key

0 commit comments

Comments
 (0)