Review SageMaker notebook encryption keys

Distinguish default notebook encryption from requirements for a customer managed key.

Description

Without kms_key_id, SageMaker encrypts a notebook instance’s operating-system and ML data volumes with a system-managed key. A customer managed key applies to the ML data volume.

Potential impact

The system-managed key may fall short of your key-management requirements. Losing access to a customer managed key in use can disrupt file access and notebook operations.

Remediation

If required, set kms_key_id to an enabled key ARN in the same Region and check its permissions. Store files that require this key under /home/ec2-user/SageMaker. Changing the key replaces the Terraform notebook instance. Back up the files, restore them to the new instance and verify them before switching.

Examples

Default encryption key

hcl
resource "aws_sagemaker_notebook_instance" "ml_notebook" {
  name          = "my-notebook-instance"
  role_arn      = aws_iam_role.sagemaker_role.arn
  instance_type = "ml.t2.medium"
}

Customer managed key

hcl
resource "aws_sagemaker_notebook_instance" "ml_notebook" {
  name          = "my-notebook-instance"
  role_arn      = aws_iam_role.sagemaker_role.arn
  instance_type = "ml.t2.medium"
  kms_key_id    = "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
}

The second example selects the ML data volume’s key. Supply the actual key ARN and execution role. Manage notebook access, S3 permissions and S3 encryption separately.

References