@@ -82,22 +82,58 @@ class KMSMasterKeyProvider(MasterKeyProvider):
82
82
Master key providers are deprecated.
83
83
Use :class:`aws_encryption_sdk.keyrings.aws_kms.AwsKmsKeyring` instead.
84
84
85
- >>> import aws_encryption_sdk
86
- >>> kms_key_provider = aws_encryption_sdk.KMSMasterKeyProvider(key_ids=[
87
- ... 'arn:aws:kms:us-east-1:2222222222222:key/22222222-2222-2222-2222-222222222222',
88
- ... 'arn:aws:kms:us-east-1:3333333333333:key/33333333-3333-3333-3333-333333333333'
85
+ To encrypt data, you must configure :class:`KMSMasterKeyProvider` with at least one CMK.
86
+ If you configure :class:`KMSMasterKeyProvider` with multiple CMKs,
87
+ it generates the data key using the first CMK and encrypts that data key using the rest,
88
+ so that the `encrypted message`_ includes a copy of the data key encrypted under each configured CMK.
89
+
90
+ .. _encrypted message: https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/message-format.html
91
+
92
+ >>> from aws_encryption_sdk.key_providers.kms import KMSMasterKeyProvider
93
+ >>> kms_key_provider = KMSMasterKeyProvider(key_ids=[
94
+ ... "arn:aws:kms:us-east-1:2222222222222:key/22222222-2222-2222-2222-222222222222",
95
+ ... "arn:aws:kms:us-east-1:3333333333333:key/33333333-3333-3333-3333-333333333333",
96
+ ... ])
97
+
98
+ You can also configure :class:`KMSMasterKeyProvider` with CMKs in multiple regions:
99
+
100
+ >>> from aws_encryption_sdk.key_providers.kms import KMSMasterKeyProvider
101
+ >>> kms_key_provider = KMSMasterKeyProvider(key_ids=[
102
+ ... "arn:aws:kms:us-east-1:2222222222222:key/22222222-2222-2222-2222-222222222222",
103
+ ... "arn:aws:kms:us-west-2:3333333333333:key/33333333-3333-3333-3333-333333333333",
104
+ ... "arn:aws:kms:ap-northeast-1:4444444444444:key/44444444-4444-4444-4444-444444444444",
89
105
... ])
90
- >>> kms_key_provider.add_master_key('arn:aws:kms:ap-northeast-1:4444444444444:alias/another-key')
91
106
92
- .. note::
93
- If no botocore_session is provided, the default botocore session will be used.
107
+ :class:`KMSMasterKeyProvider` needs AWS credentials in order to interact with `AWS KMS`_.
108
+ There are two ways that you can provide these credentials:
109
+
110
+ .. _AWS KMS: https://docs.aws.amazon.com/kms/latest/developerguide/overview.html
111
+
112
+ 1. Provide your AWS credentials in one of the standard `AWS credential discovery locations`_
113
+ and the :class:`KMSMasterKeyProvider` instance automatically discovers those credentials.
114
+
115
+ .. _AWS credential discovery locations:
116
+ https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html#configuring-credentials
117
+
118
+ >>> from aws_encryption_sdk.key_providers.kms import KMSMasterKeyProvider
119
+ >>> import botocore.session
120
+ >>> kms_key_provider = KMSMasterKeyProvider()
94
121
95
- .. note::
96
- If multiple AWS Identities are needed, one of two options are available:
122
+ 2. Provide an existing botocore session to :class:`KMSMasterKeyProvider`.
123
+ This option can be useful if you want to use specific credentials
124
+ or if you want to reuse an existing botocore session instance to decrease startup costs.
97
125
98
- * Additional KMSMasterKeyProvider instances may be added to the primary MasterKeyProvider.
126
+ >>> from aws_encryption_sdk.key_providers.kms import KMSMasterKeyProvider
127
+ >>> import botocore.session
128
+ >>> existing_botocore_session = botocore.session.Session(profile="custom")
129
+ >>> kms_key_provider = KMSMasterKeyProvider(botocore_session=existing_botocore_session)
99
130
100
- * KMSMasterKey instances may be manually created and added to this KMSMasterKeyProvider.
131
+ If you need different credentials to use different CMKs,
132
+ you can combine multiple :class:`KMSMasterKeyProvider` or :class:`KMSMasterKey` instances,
133
+ each with their own credentials.
134
+ However, we recommend that you use
135
+ :class:`aws_encryption_sdk.keyrings.aws_kms.AwsKmsKeyring` and client suppliers
136
+ for a simpler user experience.
101
137
102
138
:param config: Configuration object (optional)
103
139
:type config: aws_encryption_sdk.key_providers.kms.KMSMasterKeyProviderConfig
0 commit comments