Skip to content

Commit b04688c

Browse files
authored
feat: AWS KMS multi-Region Key support (#216)
CLI now supports Multi-Region Keys (MRKs). Usage of MRKs is identical to the usage of non-MRK KMS Keys. Though a KMS Key does not have to be a MRK Key for it to be used. See https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-overview.html for more details about AWS KMS multi-Region Keys. See https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/configure.html#config-mrks for more details about how the AWS Encryption SDK interoperates with AWS KMS multi-Region keys.
1 parent c6b0253 commit b04688c

File tree

15 files changed

+67
-19
lines changed

15 files changed

+67
-19
lines changed

CHANGELOG.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22
Changelog
33
*********
44

5+
3.0.0 -- 2021-06-16
6+
===================
7+
8+
Features
9+
--------
10+
* AWS KMS multi-Region Key support
11+
12+
CLI now supports Multi-Region Keys (MRKs).
13+
Usage of MRKs is identical to the usage of non-MRK KMS Keys.
14+
Though a KMS Key does not have to be a MRK key for it to be used.
15+
16+
See https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-overview.html
17+
for more details about AWS KMS multi-Region Keys.
18+
19+
See https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/configure.html#config-mrks
20+
for more details about how the AWS Encryption SDK interoperates
21+
with AWS KMS multi-Region keys.
22+
523
2.2.0 -- 2021-05-27
624
===================
725

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
aws-encryption-sdk-cli==3.0.0

api_compatibility_tests/tox.ini

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
envlist =
3-
py38-awses_cli_{1.7.0,1.8.0,1.9.0,2.0.0,2.1.0,2.2.0}
3+
py38-awses_cli_{1.7.0,1.8.0,1.9.0,2.0.0,2.1.0,2.2.0,3.0.0}
44

55
[testenv:base-command]
66
commands = pytest --basetemp={envtmpdir} -l test/ {posargs}
@@ -9,13 +9,18 @@ commands = pytest --basetemp={envtmpdir} -l test/ {posargs}
99
passenv =
1010
# Identifies AWS KMS key id to use in integration tests
1111
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID \
12+
# Identifies AWS MRK KMS key id to use in integration tests
13+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1 \
1214
# Pass through AWS credentials
1315
AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN \
1416
# AWS Role access in CodeBuild is via the contaner URI
1517
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI \
1618
# Pass through AWS profile name (useful for local testing)
1719
AWS_PROFILE \
18-
# Pass through custom pip config file settings
20+
# The region for the MRK aware components
21+
AWS_REGION \
22+
AWS_DEFAULT_REGION \
23+
# Pass through custom pip config file settings
1924
PIP_CONFIG_FILE
2025
sitepackages = False
2126
deps =
@@ -26,6 +31,7 @@ deps =
2631
awses_cli_2.0.0: -rcompatibility-requirements/2.0.0
2732
awses_cli_2.1.0: -rcompatibility-requirements/2.1.0
2833
awses_cli_2.2.0: -rcompatibility-requirements/2.2.0
34+
awses_cli_3.0.0: -rcompatibility-requirements/3.0.0
2935
awses_cli_local: -e {env:AWSES_CLI_LOCAL_PATH}
3036
commands =
3137
{[testenv:base-command]commands}

codebuild/python_27.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ env:
55
TOXENV: "py27-integ"
66
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
77
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
8+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
9+
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
810
911
phases:
1012
install:

codebuild/python_35.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ env:
55
TOXENV: "py35-integ"
66
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
77
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
8+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
9+
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
810
911
phases:
1012
install:

codebuild/python_36.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ env:
55
TOXENV: "py36-integ"
66
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
77
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
8+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
9+
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
810
911
phases:
1012
install:

codebuild/python_37.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ env:
55
TOXENV: "py37-integ"
66
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
77
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
8+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
9+
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
810
911
phases:
1012
install:

codebuild/python_38.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ env:
55
TOXENV: "py38-integ"
66
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
77
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
8+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
9+
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
810
911
phases:
1012
install:

codebuild/release/validate.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ env:
44
variables:
55
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
66
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
7+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
8+
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
79
810
phases:
911
install:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
base64io>=1.0.1
2-
aws-encryption-sdk~=2.2
2+
aws-encryption-sdk~=2.3
33
setuptools
44
attrs>=17.1.0

src/aws_encryption_sdk_cli/internal/identifiers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"DEFAULT_MASTER_KEY_PROVIDER",
3232
"OperationResult",
3333
)
34-
__version__ = "2.2.0" # type: str
34+
__version__ = "3.0.0" # type: str
3535

3636
#: Suffix added to output files if specific output filename is not specified.
3737
OUTPUT_SUFFIX = {

src/aws_encryption_sdk_cli/key_providers.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
import copy
1515

1616
import botocore.session
17-
from aws_encryption_sdk import DiscoveryAwsKmsMasterKeyProvider, StrictAwsKmsMasterKeyProvider
18-
from aws_encryption_sdk.key_providers.kms import DiscoveryFilter
17+
from aws_encryption_sdk.key_providers.kms import (
18+
DiscoveryFilter,
19+
MRKAwareDiscoveryAwsKmsMasterKeyProvider,
20+
MRKAwareStrictAwsKmsMasterKeyProvider,
21+
)
1922

2023
from aws_encryption_sdk_cli.exceptions import BadUserArgumentError
2124
from aws_encryption_sdk_cli.internal.identifiers import USER_AGENT_SUFFIX
@@ -29,13 +32,16 @@
2932
__all__ = ("aws_kms_master_key_provider",)
3033

3134

32-
def aws_kms_master_key_provider(discovery=True, **kwargs):
33-
# type: (bool, **List[Union[Text, str]]) -> Union[DiscoveryAwsKmsMasterKeyProvider, StrictAwsKmsMasterKeyProvider]
35+
def aws_kms_master_key_provider(
36+
discovery=True, # type: bool
37+
**kwargs # type: List[Union[Text, str]]
38+
):
39+
# type: (...) -> Union[MRKAwareDiscoveryAwsKmsMasterKeyProvider, MRKAwareStrictAwsKmsMasterKeyProvider]
3440
"""Apply post-processing to transform ``KMSMasterKeyProvider``-specific values from CLI
35-
arguments to valid ``KMSMasterKeyProvider`` parameters, then call ``KMSMasterKeyprovider``
41+
arguments to valid ``KMSMasterKeyProvider`` parameters, then call ``KMSMasterKeyProvider``
3642
with those parameters.
3743
38-
:param bool discovery: Return a DiscoveryAwsKmsMasterKeyProvider
44+
:param bool discovery: Return a MRKAwareDiscoveryAwsKmsMasterKeyProvider
3945
:param dict kwargs: Named parameters collected from CLI arguments as prepared
4046
in aws_encryption_sdk_cli.internal.master_key_parsing._parse_master_key_providers_from_args
4147
:rtype: aws_encryption_sdk.key_providers.kms.BaseKMSMasterKeyProvider
@@ -75,5 +81,5 @@ def aws_kms_master_key_provider(discovery=True, **kwargs):
7581
discovery_filter = DiscoveryFilter(account_ids=accounts, partition=partition)
7682
kwargs["discovery_filter"] = discovery_filter # type: ignore
7783

78-
return DiscoveryAwsKmsMasterKeyProvider(**kwargs)
79-
return StrictAwsKmsMasterKeyProvider(**kwargs)
84+
return MRKAwareDiscoveryAwsKmsMasterKeyProvider(**kwargs)
85+
return MRKAwareStrictAwsKmsMasterKeyProvider(**kwargs)

test/unit/test_aws_encryption_sdk_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ def test_cli_unknown_error_capture_stacktrace(patch_process_cli_request, tmpdir,
781781
+ str(tmpdir.join("ciphertext"))
782782
+ " "
783783
+ requested_log_level
784-
+ " -w discovery=true"
784+
+ " -w discovery=true region=us-west-2"
785785
)
786786
)
787787

test/unit/test_key_providers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ def patch_botocore_session(mocker):
3838

3939
@pytest.yield_fixture
4040
def patch_discovery_master_key_provider(mocker):
41-
mocker.patch.object(key_providers, "DiscoveryAwsKmsMasterKeyProvider")
42-
yield key_providers.DiscoveryAwsKmsMasterKeyProvider
41+
mocker.patch.object(key_providers, "MRKAwareDiscoveryAwsKmsMasterKeyProvider")
42+
yield key_providers.MRKAwareDiscoveryAwsKmsMasterKeyProvider
4343

4444

4545
@pytest.yield_fixture
4646
def patch_strict_master_key_provider(mocker):
47-
mocker.patch.object(key_providers, "StrictAwsKmsMasterKeyProvider")
48-
yield key_providers.StrictAwsKmsMasterKeyProvider
47+
mocker.patch.object(key_providers, "MRKAwareStrictAwsKmsMasterKeyProvider")
48+
yield key_providers.MRKAwareStrictAwsKmsMasterKeyProvider
4949

5050

5151
@pytest.mark.parametrize(

tox.ini

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,17 @@ envlist =
3737
passenv =
3838
# Identifies AWS KMS key id to use in integration tests
3939
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID \
40+
# Identifies AWS MRK KMS key id to use in integration tests
41+
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1 \
4042
# Pass through AWS credentials
4143
AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN \
4244
# AWS Role access in CodeBuild is via the contaner URI
4345
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI \
4446
# Pass through AWS profile name (useful for local testing)
4547
AWS_PROFILE \
48+
# The region for the MRK aware components
49+
AWS_REGION \
50+
AWS_DEFAULT_REGION \
4651
# Pass through custom pip config file settings
4752
PIP_CONFIG_FILE
4853

@@ -78,8 +83,8 @@ basepython = python3
7883
deps =
7984
# mypy outputs coverage data in a coverage 4.x format
8085
coverage~=4.0
81-
mypy
82-
mypy_extensions
86+
mypy==0.812
87+
mypy_extensions==0.4.3
8388
typing>=3.6.2
8489

8590
[testenv:mypy-py3]

0 commit comments

Comments
 (0)