Skip to content

fix KMSMasterKeyProvider to determine the default region before trying to create the requested master keys #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
Changelog
*********

1.3.7 -- 2018-09-17
===================

Bugfixes
--------

* Fix KMSMasterKeyProvider to determine the default region before trying to create the requested master keys.
`#83 <https://github.com/aws/aws-encryption-sdk-python/issues/83>`_


1.3.6 -- 2018-09-04
===================

Expand Down
2 changes: 1 addition & 1 deletion src/aws_encryption_sdk/identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from aws_encryption_sdk.exceptions import InvalidAlgorithmError

__version__ = "1.3.6"
__version__ = "1.3.7"
USER_AGENT_SUFFIX = "AwsEncryptionSdkPython/{}".format(__version__)


Expand Down
6 changes: 4 additions & 2 deletions src/aws_encryption_sdk/key_providers/kms.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ def __init__(self, **kwargs): # pylint: disable=unused-argument
def _process_config(self):
"""Traverses the config and adds master keys and regional clients as needed."""
self._user_agent_adding_config = botocore.config.Config(user_agent_extra=USER_AGENT_SUFFIX)
if self.config.key_ids:
self.add_master_keys_from_list(self.config.key_ids)

if self.config.region_names:
self.add_regional_clients_from_list(self.config.region_names)
self.default_region = self.config.region_names[0]
Expand All @@ -126,6 +125,9 @@ def _process_config(self):
if self.default_region is not None:
self.add_regional_client(self.default_region)

if self.config.key_ids:
self.add_master_keys_from_list(self.config.key_ids)

def add_regional_client(self, region_name):
"""Adds a regional client for the specified region if it does not already exist.

Expand Down
7 changes: 7 additions & 0 deletions test/unit/test_providers_kms_master_key_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
pytestmark = [pytest.mark.unit, pytest.mark.local]


def test_init_with_regionless_key_ids_and_region_names():
key_ids = ("alias/key_1",)
region_names = ("test-region-1",)
provider = KMSMasterKeyProvider(region_names=region_names, key_ids=key_ids)
assert provider.master_key("alias/key_1").config.client.meta.region_name == region_names[0]


class TestKMSMasterKeyProvider(unittest.TestCase):
def setUp(self):
self.mock_botocore_session_patcher = patch("aws_encryption_sdk.key_providers.kms.botocore.session.Session")
Expand Down