Skip to content

chore(multi-threaded-examples): Added keyring examples #693

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

Closed
wants to merge 18 commits into from
Closed
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
6 changes: 1 addition & 5 deletions .github/workflows/ci_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ jobs:
matrix:
os:
- ubuntu-latest
# Windows fails due to "No module named 'Wrappers'"
# This SHOULD be fixed once Dafny generates fully-qualified import statements
# (i.e. doo files, per-package module names)
# Disable for now
# - windows-latest
- windows-latest
- macos-12
python:
- 3.8
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ __pycache__
.pytest_cache
# Ignore key materials generated by examples or tests
test_keyrings/
# Ignore results of performance test
performance_tests/results/*.csv
performance_tests/results/*.pstats
performance_tests/results/*.png
# Ignore the memory profile logs
mprofile_*

# PyCharm
.idea/
Expand Down
8 changes: 8 additions & 0 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ batch:
buildspec: codebuild/py311/integ_mpl.yml
env:
image: aws/codebuild/standard:7.0
- identifier: py311_performance_tests_mpl
buildspec: codebuild/py311/performance_tests_mpl.yml
env:
image: aws/codebuild/standard:7.0
- identifier: py311_examples
buildspec: codebuild/py311/examples.yml
env:
Expand Down Expand Up @@ -212,6 +216,10 @@ batch:
buildspec: codebuild/py312/integ_mpl.yml
env:
image: aws/codebuild/standard:7.0
- identifier: py312_performance_tests_mpl
buildspec: codebuild/py312/performance_tests_mpl.yml
env:
image: aws/codebuild/standard:7.0
- identifier: py312_examples
buildspec: codebuild/py312/examples.yml
env:
Expand Down
38 changes: 38 additions & 0 deletions codebuild/py311/performance_tests_mpl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Runs the performance tests for the MPL in an environment with the MPL installed
version: 0.2

env:
variables:
# No TOXENV. This runs multiple environments.
REGION: "us-west-2"
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >-
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7

phases:
install:
runtime-versions:
python: 3.11
build:
commands:
- cd /root/.pyenv/plugins/python-build/../.. && git pull && cd -
- pyenv install --skip-existing 3.11.0
- pyenv local 3.11.0
- pip install --upgrade pip
- pip install setuptools
- pip install "tox < 4.0"
# Assume special role to access keystore
- TMP_ROLE=$(aws sts assume-role --role-arn "arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Python-Role-us-west-2" --role-session-name "CB-Py312ExamplesMpl")
- export TMP_ROLE
- export AWS_ACCESS_KEY_ID=$(echo "${TMP_ROLE}" | jq -r '.Credentials.AccessKeyId')
- export AWS_SECRET_ACCESS_KEY=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SecretAccessKey')
- export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken')
- aws sts get-caller-identity
# Run MPL-specific tests with special role
- cd performance_tests/
- tox -e py311-performance_tests-mpl
38 changes: 38 additions & 0 deletions codebuild/py312/performance_tests_mpl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Runs the performance tests for the MPL in an environment with the MPL installed
version: 0.2

env:
variables:
# No TOXENV. This runs multiple environments.
REGION: "us-west-2"
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID: >-
arn:aws:kms:us-west-2:658956600833:key/b3537ef1-d8dc-4780-9f5a-55776cbb2f7f
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_KEY_ID_2: >-
arn:aws:kms:eu-central-1:658956600833:key/75414c93-5285-4b57-99c9-30c1cf0a22c2
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_1: >-
arn:aws:kms:us-west-2:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7
AWS_ENCRYPTION_SDK_PYTHON_INTEGRATION_TEST_AWS_KMS_MRK_KEY_ID_2: >-
arn:aws:kms:us-east-1:658956600833:key/mrk-80bd8ecdcd4342aebd84b7dc9da498a7

phases:
install:
runtime-versions:
python: 3.12
build:
commands:
- cd /root/.pyenv/plugins/python-build/../.. && git pull && cd -
- pyenv install --skip-existing 3.12.0
- pyenv local 3.12.0
- pip install --upgrade pip
- pip install setuptools
- pip install "tox < 4.0"
# Assume special role to access keystore
- TMP_ROLE=$(aws sts assume-role --role-arn "arn:aws:iam::370957321024:role/GitHub-CI-Public-ESDK-Python-Role-us-west-2" --role-session-name "CB-Py312ExamplesMpl")
- export TMP_ROLE
- export AWS_ACCESS_KEY_ID=$(echo "${TMP_ROLE}" | jq -r '.Credentials.AccessKeyId')
- export AWS_SECRET_ACCESS_KEY=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SecretAccessKey')
- export AWS_SESSION_TOKEN=$(echo "${TMP_ROLE}" | jq -r '.Credentials.SessionToken')
- aws sts get-caller-identity
# Run MPL-specific tests with special role
- cd performance_tests/
- tox -e py312-performance_tests-mpl
6 changes: 0 additions & 6 deletions examples/src/aws_kms_discovery_keyring_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
For more information on how to use KMS Discovery keyrings, see
https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html#kms-keyring-discovery
"""
import sys

import boto3
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
Expand All @@ -49,11 +48,6 @@
from aws_encryption_sdk import CommitmentPolicy
from aws_encryption_sdk.exceptions import AWSEncryptionSDKClientError

# TODO-MPL: Remove this as part of removing PYTHONPATH hacks.
MODULE_ROOT_DIR = '/'.join(__file__.split("/")[:-1])

sys.path.append(MODULE_ROOT_DIR)

EXAMPLE_DATA: bytes = b"Hello World"


Expand Down
6 changes: 0 additions & 6 deletions examples/src/aws_kms_discovery_multi_keyring_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
For more information on how to use KMS Discovery keyrings, see
https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html#kms-keyring-discovery
"""
import sys

import boto3
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
Expand All @@ -45,11 +44,6 @@
import aws_encryption_sdk
from aws_encryption_sdk import CommitmentPolicy

# TODO-MPL: Remove this as part of removing PYTHONPATH hacks.
MODULE_ROOT_DIR = '/'.join(__file__.split("/")[:-1])

sys.path.append(MODULE_ROOT_DIR)

EXAMPLE_DATA: bytes = b"Hello World"


Expand Down
6 changes: 0 additions & 6 deletions examples/src/aws_kms_keyring_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
For more information on how to use KMS keyrings, see
https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html
"""
import sys

import boto3
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
Expand All @@ -29,11 +28,6 @@
import aws_encryption_sdk
from aws_encryption_sdk import CommitmentPolicy

# TODO-MPL: Remove this as part of removing PYTHONPATH hacks.
MODULE_ROOT_DIR = '/'.join(__file__.split("/")[:-1])

sys.path.append(MODULE_ROOT_DIR)

EXAMPLE_DATA: bytes = b"Hello World"


Expand Down
6 changes: 0 additions & 6 deletions examples/src/aws_kms_mrk_discovery_keyring_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
For more information on how to use KMS Discovery keyrings, see
https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html#kms-keyring-discovery
"""
import sys

import boto3
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
Expand All @@ -50,11 +49,6 @@
import aws_encryption_sdk
from aws_encryption_sdk import CommitmentPolicy

# TODO-MPL: Remove this as part of removing PYTHONPATH hacks.
MODULE_ROOT_DIR = '/'.join(__file__.split("/")[:-1])

sys.path.append(MODULE_ROOT_DIR)

EXAMPLE_DATA: bytes = b"Hello World"


Expand Down
6 changes: 0 additions & 6 deletions examples/src/aws_kms_mrk_discovery_multi_keyring_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
For more information on how to use KMS Discovery keyrings, see
https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html#kms-keyring-discovery
"""
import sys

import boto3
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
Expand All @@ -52,11 +51,6 @@
import aws_encryption_sdk
from aws_encryption_sdk import CommitmentPolicy

# TODO-MPL: Remove this as part of removing PYTHONPATH hacks.
MODULE_ROOT_DIR = '/'.join(__file__.split("/")[:-1])

sys.path.append(MODULE_ROOT_DIR)

EXAMPLE_DATA: bytes = b"Hello World"


Expand Down
6 changes: 0 additions & 6 deletions examples/src/aws_kms_mrk_keyring_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
For more info on KMS MRK (multi-region keys), see the KMS documentation:
https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-overview.html
"""
import sys

import boto3
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
Expand All @@ -33,11 +32,6 @@
import aws_encryption_sdk
from aws_encryption_sdk import CommitmentPolicy

# TODO-MPL: Remove this as part of removing PYTHONPATH hacks.
MODULE_ROOT_DIR = '/'.join(__file__.split("/")[:-1])

sys.path.append(MODULE_ROOT_DIR)

EXAMPLE_DATA: bytes = b"Hello World"


Expand Down
6 changes: 0 additions & 6 deletions examples/src/aws_kms_mrk_multi_keyring_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
For more info on KMS MRK (multi-region keys), see the KMS documentation:
https://docs.aws.amazon.com/kms/latest/developerguide/multi-region-keys-overview.html
"""
import sys

import boto3
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
Expand All @@ -39,11 +38,6 @@
import aws_encryption_sdk
from aws_encryption_sdk import CommitmentPolicy

# TODO-MPL: Remove this as part of removing PYTHONPATH hacks.
MODULE_ROOT_DIR = '/'.join(__file__.split("/")[:-1])

sys.path.append(MODULE_ROOT_DIR)

EXAMPLE_DATA: bytes = b"Hello World"


Expand Down
6 changes: 0 additions & 6 deletions examples/src/aws_kms_multi_keyring_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
For more information on how to use Multi keyrings, see
https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-multi-keyring.html
"""
import sys

import boto3
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
Expand All @@ -48,11 +47,6 @@
import aws_encryption_sdk
from aws_encryption_sdk import CommitmentPolicy

# TODO-MPL: Remove this as part of removing PYTHONPATH hacks.
MODULE_ROOT_DIR = '/'.join(__file__.split("/")[:-1])

sys.path.append(MODULE_ROOT_DIR)

EXAMPLE_DATA: bytes = b"Hello World"


Expand Down
6 changes: 0 additions & 6 deletions examples/src/aws_kms_rsa_keyring_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# For more information on how to use KMS keyrings, see
# https://docs.aws.amazon.com/encryption-sdk/latest/developer-guide/use-kms-keyring.html
"""
import sys

import boto3
from aws_cryptographic_materialproviders.mpl import AwsCryptographicMaterialProviders
Expand All @@ -27,11 +26,6 @@
from aws_encryption_sdk import CommitmentPolicy
from aws_encryption_sdk.identifiers import AlgorithmSuite

# TODO-MPL: Remove this as part of removing PYTHONPATH hacks.
MODULE_ROOT_DIR = '/'.join(__file__.split("/")[:-1])

sys.path.append(MODULE_ROOT_DIR)

EXAMPLE_DATA: bytes = b"Hello World"


Expand Down
Loading
Loading