16
16
import attr
17
17
import boto3
18
18
import botocore .client
19
+ import botocore .config
19
20
from botocore .exceptions import ClientError
20
21
import botocore .session
21
22
22
23
from aws_encryption_sdk .exceptions import DecryptKeyError , EncryptKeyError , GenerateKeyError , UnknownRegionError
23
24
from aws_encryption_sdk .identifiers import USER_AGENT_SUFFIX
24
25
from aws_encryption_sdk .internal .str_ops import to_str
25
- from aws_encryption_sdk .internal .utils import extend_user_agent_suffix
26
26
from aws_encryption_sdk .key_providers .base import (
27
27
MasterKey , MasterKeyConfig , MasterKeyProvider , MasterKeyProviderConfig
28
28
)
@@ -101,6 +101,7 @@ def __init__(self, **kwargs): # pylint: disable=unused-argument
101
101
102
102
def _process_config (self ):
103
103
"""Traverses the config and adds master keys and regional clients as needed."""
104
+ self ._user_agent_adding_config = botocore .config .Config (user_agent_extra = USER_AGENT_SUFFIX )
104
105
if self .config .key_ids :
105
106
self .add_master_keys_from_list (self .config .key_ids )
106
107
if self .config .region_names :
@@ -120,7 +121,7 @@ def add_regional_client(self, region_name):
120
121
self ._regional_clients [region_name ] = boto3 .session .Session (
121
122
region_name = region_name ,
122
123
botocore_session = self .config .botocore_session
123
- ).client ('kms' )
124
+ ).client ('kms' , config = self . _user_agent_adding_config )
124
125
125
126
def add_regional_clients_from_list (self , region_names ):
126
127
"""Adds multiple regional clients for the specified regions if they do not already exist.
@@ -200,10 +201,6 @@ class KMSMasterKey(MasterKey):
200
201
def __init__ (self , ** kwargs ): # pylint: disable=unused-argument
201
202
"""Performs transformations needed for KMS."""
202
203
self ._key_id = to_str (self .key_id ) # KMS client requires str, not bytes
203
- self .config .client .meta .config .user_agent_extra = extend_user_agent_suffix (
204
- user_agent = self .config .client .meta .config .user_agent_extra ,
205
- suffix = USER_AGENT_SUFFIX
206
- )
207
204
208
205
def _generate_data_key (self , algorithm , encryption_context = None ):
209
206
"""Generates data key and returns plaintext and ciphertext of key.
0 commit comments