Skip to content

Commit 87f9ccb

Browse files
Refactor examples into sub-module (#163)
This lets us use the examples during release validation -- simply update the dynamodb-encryption-sdk dependency to point to the specific version we want to validate.
1 parent e740ba0 commit 87f9ccb

17 files changed

+140
-9
lines changed

examples/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# AWS DynamoDB Encryption Client Examples
2+
3+
This section features examples that show you
4+
how to use the AWS DynamoDB Encryption Client.
5+
We demonstrate how to use the encryption and decryption APIs
6+
and how to set up some common configuration patterns.
7+
8+
## APIs
9+
10+
The AWS DynamoDB Encryption Client provides four high-level APIs: `EncryptedClient`, `EncryptedItem`,
11+
`EncryptedResource`, and `EncryptedTable`.
12+
13+
You can find examples that demonstrate these APIs
14+
in the [`examples/src/dynamodb_encryption_sdk_examples`](./src/dynamodb_encryption_sdk_examples) directory.
15+
Each of these examples uses AWS KMS as the materials provider.
16+
17+
* [How to use the EncryptedClient API](./src/dynamodb_encryption_sdk_examples/aws_kms_encrypted_client.py)
18+
* [How to use the EncryptedItem API](./src/dynamodb_encryption_sdk_examples/aws_kms_encrypted_item.py)
19+
* [How to use the EncryptedResource API](./src/dynamodb_encryption_sdk_examples/aws_kms_encrypted_resource.py)
20+
* [How to use the EncryptedTable API](./src/dynamodb_encryption_sdk_examples/aws_kms_encrypted_table.py)
21+
22+
## Material Providers
23+
24+
To use the encryption and decryption APIs, you need to describe how you want the library to protect your data keys.
25+
You can do this by configuring material providers. AWS KMS is the most common material provider used with the AWS DynamoDB Encryption
26+
SDK, and each of the API examples above uses AWS KMS. This section describes the other providers that come bundled
27+
with this library.
28+
29+
* [How to use the CachingMostRecentProvider](./src/dynamodb_encryption_sdk_examples/most_recent_provider_encrypted_table.py)
30+
* [How to use raw symmetric wrapping keys](./src/dynamodb_encryption_sdk_examples/wrapped_symmetric_encrypted_table.py)
31+
* [How to use raw asymmetric wrapping keys](./src/dynamodb_encryption_sdk_examples/wrapped_rsa_encrypted_table.py)
32+
33+
For more details on the different type of material providers, see [How to choose a cryptographic materials provider](https://docs.aws.amazon.com/dynamodb-encryption-client/latest/devguide/crypto-materials-providers.html).

examples/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dynamodb-encryption-sdk

examples/setup.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"""DynamoDB Encryption Client for Python examples."""
2+
import io
3+
import os
4+
import re
5+
6+
from setuptools import find_packages, setup
7+
8+
VERSION_RE = re.compile(r"""__version__ = ['"]([0-9.]+)['"]""")
9+
HERE = os.path.abspath(os.path.dirname(__file__))
10+
11+
12+
def read(*args):
13+
"""Reads complete file contents."""
14+
return io.open(os.path.join(HERE, *args), encoding="utf-8").read()
15+
16+
17+
def get_version():
18+
"""Reads the version from this module."""
19+
init = read("src", "dynamodb_encryption_sdk_examples", "__init__.py")
20+
return VERSION_RE.search(init).group(1)
21+
22+
23+
def get_requirements():
24+
"""Reads the requirements file."""
25+
requirements = read("requirements.txt")
26+
return requirements.strip().splitlines()
27+
28+
29+
setup(
30+
name="dynamodb-encryption-sdk-examples",
31+
version=get_version(),
32+
packages=find_packages("src"),
33+
package_dir={"": "src"},
34+
url="https://github.com/aws/aws-dynamodb-encryption-python",
35+
author="Amazon Web Services",
36+
author_email="[email protected]",
37+
maintainer="Amazon Web Services",
38+
description="DynamoDB Encryption Client for Python examples",
39+
long_description=read("README.rst"),
40+
keywords="dynamodb-encryption-sdk aws kms encryption dynamodb",
41+
data_files=["requirements.txt"],
42+
license="Apache License 2.0",
43+
install_requires=get_requirements(),
44+
classifiers=[
45+
"Development Status :: 5 - Production/Stable",
46+
"Intended Audience :: Developers",
47+
"Natural Language :: English",
48+
"License :: OSI Approved :: Apache Software License",
49+
"Programming Language :: Python",
50+
"Programming Language :: Python :: 2",
51+
"Programming Language :: Python :: 2.7",
52+
"Programming Language :: Python :: 3",
53+
"Programming Language :: Python :: 3.5",
54+
"Programming Language :: Python :: 3.6",
55+
"Programming Language :: Python :: 3.7",
56+
"Programming Language :: Python :: 3.8",
57+
"Programming Language :: Python :: 3.9",
58+
"Programming Language :: Python :: Implementation :: CPython",
59+
"Topic :: Security",
60+
"Topic :: Security :: Cryptography",
61+
],
62+
)

examples/src/__init__.py renamed to examples/src/dynamodb_encryption_sdk_examples/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
1313
"""Stub module indicator to make linter configuration simpler."""
14+
__version__ = "1.0.0"

0 commit comments

Comments
 (0)