-
Notifications
You must be signed in to change notification settings - Fork 1.2k
change: add KMS key option for Endpoint Configs #762
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
from sagemaker.mxnet.model import MXNetModel | ||
from sagemaker.utils import sagemaker_timestamp | ||
from tests.integ import DATA_DIR, PYTHON_VERSION, TRAINING_DEFAULT_TIMEOUT_MINUTES | ||
from tests.integ.kms_utils import get_or_create_kms_key | ||
from tests.integ.timeout import timeout, timeout_and_delete_endpoint_by_name | ||
|
||
|
||
|
@@ -109,6 +110,30 @@ def test_deploy_model_with_tags(mxnet_training_job, sagemaker_session, mxnet_ful | |
assert production_variants[0]['InitialInstanceCount'] == 1 | ||
|
||
|
||
def test_deploy_model_with_kms_key(mxnet_training_job, sagemaker_session, mxnet_full_version): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we just add this to an existing test? They are already taking so long to run use so much resource. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
endpoint_name = 'test-mxnet-deploy-model-{}'.format(sagemaker_timestamp()) | ||
|
||
with timeout_and_delete_endpoint_by_name(endpoint_name, sagemaker_session): | ||
desc = sagemaker_session.sagemaker_client.describe_training_job(TrainingJobName=mxnet_training_job) | ||
model_data = desc['ModelArtifacts']['S3ModelArtifacts'] | ||
script_path = os.path.join(DATA_DIR, 'mxnet_mnist', 'mnist.py') | ||
model = MXNetModel(model_data, 'SageMakerRole', entry_point=script_path, | ||
py_version=PYTHON_VERSION, sagemaker_session=sagemaker_session, | ||
framework_version=mxnet_full_version) | ||
|
||
sts_client = sagemaker_session.boto_session.client('sts') | ||
account_id = sts_client.get_caller_identity()['Account'] | ||
kms_client = sagemaker_session.boto_session.client('kms') | ||
kms_key_arn = get_or_create_kms_key(kms_client, account_id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional - I think it will make this code cleaner if get_or_create_kms_key just take sageamker_session as the argument. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
model.deploy(1, 'ml.m4.xlarge', endpoint_name=endpoint_name, kms_key=kms_key_arn) | ||
|
||
endpoint = sagemaker_session.describe_endpoint(EndpointName=endpoint_name) | ||
endpoint_config = sagemaker_session.describe_endpoint_config(EndpointConfigName=endpoint['EndpointConfigName']) | ||
|
||
assert endpoint_config['KmsKeyId'] == kms_key_arn | ||
|
||
|
||
def test_deploy_model_with_update_endpoint(mxnet_training_job, sagemaker_session, mxnet_full_version): | ||
endpoint_name = 'test-mxnet-deploy-model-{}'.format(sagemaker_timestamp()) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it clear that this is the arn of the kms_key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done