Skip to content

Commit 1815399

Browse files
committed
chore: change examples parameter from aws_kms_cmk_arn to aws_kms_cmk for consistency
1 parent 95047f1 commit 1815399

12 files changed

+32
-32
lines changed

examples/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ please make sure that it meets the following requirements:
7676
1. Each example file MUST contain a function called `run` that runs the example.
7777
1. If your `run` function needs any of the following inputs,
7878
the parameters MUST have the following names:
79-
* `aws_kms_cmk_arn` (`str`) : A single AWS KMS CMK ARN.
79+
* `aws_kms_cmk` (`str`) : A single AWS KMS CMK ARN.
8080
* NOTE: You can assume that automatically discovered credentials have
8181
`kms:GenerateDataKey`, `kms:Encrypt`, and `kms:Decrypt` permissions on this CMK.
8282
* `aws_kms_generator_cmk` (`str`) : A single AWS KMS CMK ARN to use as a generator key.

examples/src/file_streaming_defaults.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
from aws_encryption_sdk.keyrings.aws_kms import KmsKeyring
1515

1616

17-
def run(aws_kms_cmk_arn, source_plaintext_filename):
17+
def run(aws_kms_cmk, source_plaintext_filename):
1818
# type: (str, str) -> None
1919
"""Demonstrate an encrypt/decrypt cycle using the streaming encrypt/decrypt APIs to work with files.
2020
21-
:param str aws_kms_cmk_arn: AWS KMS CMK ARN to use to protect data keys
21+
:param str aws_kms_cmk: AWS KMS CMK ARN to use to protect data keys
2222
:param str source_plaintext_filename: Path to plaintext file to encrypt
2323
"""
2424
# We assume that you can also write in the directory containing the plaintext file,
@@ -36,7 +36,7 @@ def run(aws_kms_cmk_arn, source_plaintext_filename):
3636
}
3737

3838
# Create the keyring that determines how your keys are protected.
39-
keyring = KmsKeyring(generator_key_id=aws_kms_cmk_arn)
39+
keyring = KmsKeyring(generator_key_id=aws_kms_cmk)
4040

4141
# Open the files you want to work with.
4242
with open(source_plaintext_filename, "rb") as plaintext, open(ciphertext_filename, "wb") as ciphertext:

examples/src/in_memory_streaming_defaults.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
from aws_encryption_sdk.keyrings.aws_kms import KmsKeyring
1515

1616

17-
def run(aws_kms_cmk_arn, source_plaintext):
17+
def run(aws_kms_cmk, source_plaintext):
1818
# type: (str, bytes) -> None
1919
"""Demonstrate an encrypt/decrypt cycle using the streaming encrypt/decrypt APIs in-memory.
2020
21-
:param str aws_kms_cmk_arn: AWS KMS CMK ARN to use to protect data keys
21+
:param str aws_kms_cmk: AWS KMS CMK ARN to use to protect data keys
2222
:param bytes source_plaintext: Plaintext to encrypt
2323
"""
2424
# Prepare your encryption context.
@@ -31,7 +31,7 @@ def run(aws_kms_cmk_arn, source_plaintext):
3131
}
3232

3333
# Create the keyring that determines how your keys are protected.
34-
keyring = KmsKeyring(generator_key_id=aws_kms_cmk_arn)
34+
keyring = KmsKeyring(generator_key_id=aws_kms_cmk)
3535

3636
ciphertext = io.BytesIO()
3737

examples/src/legacy/basic_encryption.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import aws_encryption_sdk
55

66

7-
def run(aws_kms_cmk_arn, source_plaintext, botocore_session=None):
7+
def run(aws_kms_cmk, source_plaintext, botocore_session=None):
88
"""Encrypts and then decrypts a string under a KMS customer master key (CMK).
99
10-
:param str aws_kms_cmk_arn: Amazon Resource Name (ARN) of the KMS CMK
10+
:param str aws_kms_cmk: Amazon Resource Name (ARN) of the KMS CMK
1111
:param bytes source_plaintext: Data to encrypt
1212
:param botocore_session: existing botocore session instance
1313
:type botocore_session: botocore.session.Session
1414
"""
1515
# Create a KMS master key provider
16-
kms_kwargs = dict(key_ids=[aws_kms_cmk_arn])
16+
kms_kwargs = dict(key_ids=[aws_kms_cmk])
1717
if botocore_session is not None:
1818
kms_kwargs["botocore_session"] = botocore_session
1919
master_key_provider = aws_encryption_sdk.KMSMasterKeyProvider(**kms_kwargs)

examples/src/legacy/basic_file_encryption_with_multiple_providers.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ def _get_raw_key(self, key_id):
5050
)
5151

5252

53-
def run(aws_kms_cmk_arn, source_plaintext_filename, botocore_session=None):
53+
def run(aws_kms_cmk, source_plaintext_filename, botocore_session=None):
5454
"""Encrypts and then decrypts a file using a KMS master key provider and a custom static master
5555
key provider. Both master key providers are used to encrypt the plaintext file, so either one alone
5656
can decrypt it.
5757
58-
:param str aws_kms_cmk_arn: Amazon Resource Name (ARN) of the KMS Customer Master Key (CMK)
58+
:param str aws_kms_cmk: Amazon Resource Name (ARN) of the KMS Customer Master Key (CMK)
5959
(http://docs.aws.amazon.com/kms/latest/developerguide/viewing-keys.html)
6060
:param str source_plaintext_filename: Filename of file to encrypt
6161
:param botocore_session: existing botocore session instance
@@ -67,7 +67,7 @@ def run(aws_kms_cmk_arn, source_plaintext_filename, botocore_session=None):
6767
cycled_static_plaintext_filename = source_plaintext_filename + ".static.decrypted"
6868

6969
# Create a KMS master key provider
70-
kms_kwargs = dict(key_ids=[aws_kms_cmk_arn])
70+
kms_kwargs = dict(key_ids=[aws_kms_cmk])
7171
if botocore_session is not None:
7272
kms_kwargs["botocore_session"] = botocore_session
7373
kms_master_key_provider = aws_encryption_sdk.KMSMasterKeyProvider(**kms_kwargs)

examples/src/legacy/data_key_caching_basic.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import aws_encryption_sdk
55

66

7-
def run(aws_kms_cmk_arn, max_age_in_cache=10.0, cache_capacity=10):
7+
def run(aws_kms_cmk, max_age_in_cache=10.0, cache_capacity=10):
88
"""Encrypts a string using an AWS KMS customer master key (CMK) and data key caching.
99
10-
:param str aws_kms_cmk_arn: Amazon Resource Name (ARN) of the KMS customer master key
10+
:param str aws_kms_cmk: Amazon Resource Name (ARN) of the KMS customer master key
1111
:param float max_age_in_cache: Maximum time in seconds that a cached entry can be used
1212
:param int cache_capacity: Maximum number of entries to retain in cache at once
1313
"""
@@ -22,7 +22,7 @@ def run(aws_kms_cmk_arn, max_age_in_cache=10.0, cache_capacity=10):
2222
encryption_context = {"purpose": "test"}
2323

2424
# Create a master key provider for the KMS customer master key (CMK)
25-
key_provider = aws_encryption_sdk.KMSMasterKeyProvider(key_ids=[aws_kms_cmk_arn])
25+
key_provider = aws_encryption_sdk.KMSMasterKeyProvider(key_ids=[aws_kms_cmk])
2626

2727
# Create a local cache
2828
cache = aws_encryption_sdk.LocalCryptoMaterialsCache(cache_capacity)

examples/src/legacy/one_kms_cmk.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
import aws_encryption_sdk
55

66

7-
def run(aws_kms_cmk_arn, source_plaintext, botocore_session=None):
7+
def run(aws_kms_cmk, source_plaintext, botocore_session=None):
88
"""Encrypts and then decrypts a string under one KMS customer master key (CMK).
99
10-
:param str aws_kms_cmk_arn: Amazon Resource Name (ARN) of the KMS CMK
10+
:param str aws_kms_cmk: Amazon Resource Name (ARN) of the KMS CMK
1111
:param bytes source_plaintext: Data to encrypt
1212
:param botocore_session: existing botocore session instance
1313
:type botocore_session: botocore.session.Session
1414
"""
15-
kwargs = dict(key_ids=[aws_kms_cmk_arn])
15+
kwargs = dict(key_ids=[aws_kms_cmk])
1616

1717
if botocore_session is not None:
1818
kwargs["botocore_session"] = botocore_session

examples/src/legacy/one_kms_cmk_streaming_data.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
import aws_encryption_sdk
77

88

9-
def run(aws_kms_cmk_arn, source_plaintext_filename, botocore_session=None):
9+
def run(aws_kms_cmk, source_plaintext_filename, botocore_session=None):
1010
"""Encrypts and then decrypts streaming data under one KMS customer master key (CMK).
1111
12-
:param str aws_kms_cmk_arn: Amazon Resource Name (ARN) of the KMS CMK
12+
:param str aws_kms_cmk: Amazon Resource Name (ARN) of the KMS CMK
1313
:param str source_plaintext_filename: Filename of file to encrypt
1414
:param botocore_session: existing botocore session instance
1515
:type botocore_session: botocore.session.Session
1616
"""
1717
kwargs = dict()
1818

19-
kwargs["key_ids"] = [aws_kms_cmk_arn]
19+
kwargs["key_ids"] = [aws_kms_cmk]
2020

2121
if botocore_session is not None:
2222
kwargs["botocore_session"] = botocore_session

examples/src/legacy/one_kms_cmk_unsigned.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
from aws_encryption_sdk.identifiers import Algorithm
88

99

10-
def run(aws_kms_cmk_arn, source_plaintext, botocore_session=None):
10+
def run(aws_kms_cmk, source_plaintext, botocore_session=None):
1111
"""Encrypts and then decrypts a string under one KMS customer master key (CMK) with an unsigned algorithm.
1212
13-
:param str aws_kms_cmk_arn: Amazon Resource Name (ARN) of the KMS CMK
13+
:param str aws_kms_cmk: Amazon Resource Name (ARN) of the KMS CMK
1414
:param bytes source_plaintext: Data to encrypt
1515
:param botocore_session: existing botocore session instance
1616
:type botocore_session: botocore.session.Session
1717
"""
18-
kwargs = dict(key_ids=[aws_kms_cmk_arn])
18+
kwargs = dict(key_ids=[aws_kms_cmk])
1919

2020
if botocore_session is not None:
2121
kwargs["botocore_session"] = botocore_session

examples/src/oneshot_defaults.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
from aws_encryption_sdk.keyrings.aws_kms import KmsKeyring
1313

1414

15-
def run(aws_kms_cmk_arn, source_plaintext):
15+
def run(aws_kms_cmk, source_plaintext):
1616
# type: (str, bytes) -> None
1717
"""Demonstrate an encrypt/decrypt cycle using the one-shot encrypt/decrypt APIs.
1818
19-
:param str aws_kms_cmk_arn: AWS KMS CMK ARN to use to protect data keys
19+
:param str aws_kms_cmk: AWS KMS CMK ARN to use to protect data keys
2020
:param bytes source_plaintext: Plaintext to encrypt
2121
"""
2222
# Prepare your encryption context.
@@ -29,7 +29,7 @@ def run(aws_kms_cmk_arn, source_plaintext):
2929
}
3030

3131
# Create the keyring that determines how your keys are protected.
32-
keyring = KmsKeyring(generator_key_id=aws_kms_cmk_arn)
32+
keyring = KmsKeyring(generator_key_id=aws_kms_cmk)
3333

3434
# Encrypt your plaintext data.
3535
ciphertext, _encrypt_header = aws_encryption_sdk.encrypt(

examples/src/oneshot_unsigned.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
from aws_encryption_sdk.keyrings.aws_kms import KmsKeyring
2626

2727

28-
def run(aws_kms_cmk_arn, source_plaintext):
28+
def run(aws_kms_cmk, source_plaintext):
2929
# type: (str, bytes) -> None
3030
"""Demonstrate requesting a specific algorithm suite through the one-shot encrypt/decrypt APIs.
3131
32-
:param str aws_kms_cmk_arn: AWS KMS CMK ARN to use to protect data keys
32+
:param str aws_kms_cmk: AWS KMS CMK ARN to use to protect data keys
3333
:param bytes source_plaintext: Plaintext to encrypt
3434
"""
3535
# Prepare your encryption context.
@@ -42,7 +42,7 @@ def run(aws_kms_cmk_arn, source_plaintext):
4242
}
4343

4444
# Create the keyring that determines how your keys are protected.
45-
keyring = KmsKeyring(generator_key_id=aws_kms_cmk_arn)
45+
keyring = KmsKeyring(generator_key_id=aws_kms_cmk)
4646

4747
# Encrypt your plaintext data.
4848
ciphertext, _encrypt_header = aws_encryption_sdk.encrypt(

examples/test/examples_test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
HERE = os.path.abspath(os.path.dirname(__file__))
2121
EXAMPLES_SOURCE = os.path.join(HERE, "..", "src")
22-
SINGLE_CMK_ARG = "aws_kms_cmk_arn"
22+
SINGLE_CMK_ARG = "aws_kms_cmk"
2323
GENERATOR_CMK_ARG = "aws_kms_generator_cmk"
2424
CHILD_CMK_ARG = "aws_kms_child_cmks"
2525
PLAINTEXT_ARG = "source_plaintext"

0 commit comments

Comments
 (0)