code: def bucket_with_encryption(sagemaker_session, sagemaker_role):
      boto_session = sagemaker_session.boto_session
      region = boto_session.region_name
      sts_client = boto_session.client(
          "sts",
          region_name=region,
          endpoint_url=utils.sts_regional_endpoint(region),
      )
  
      account = sts_client.get_caller_identity()["Account"]
      role_arn = sts_client.get_caller_identity()["Arn"]
  
      kms_client = boto_session.client("kms", region_name=region)
      kms_key_arn = _create_kms_key(
          kms_client, account, region, role_arn, sagemaker_role, None
      )
  
      region = boto_session.region_name
      bucket_name = "sagemaker-{}-{}-with-kms".format(region, account)
  
      sagemaker_session._create_s3_bucket_if_it_does_not_exist(
          bucket_name=bucket_name, region=region
      )
  
      s3_client = boto_session.client("s3", region_name=region)
      s3_client.put_bucket_encryption(
          Bucket=bucket_name,
          ServerSideEncryptionConfiguration={
              "Rules": [
                  {
                      "ApplyServerSideEncryptionByDefault": {
                          "SSEAlgorithm": "aws:kms",
                          "KMSMasterKeyID": kms_key_arn,
                      }
                  }
              ]
          },
      )
  
      s3_client.put_bucket_policy(
          Bucket=bucket_name,
          Policy=KMS_BUCKET_POLICY.format(
              partition=utils._aws_partition(region),
              bucket_name=bucket_name,
          ),
      )
  
      yield "s3://" + bucket_name, kms_key_arn
  
      kms_client.schedule_key_deletion(
          KeyId=kms_key_arn, PendingWindowInDays=7
      )
  
file_path: sagemaker-python-sdk/tests/integ/kms_utils.py
imports: from __future__ import absolute_import
  import contextlib
  import json
  from sagemaker import utils
label_desc: Use image node_id 6 for calling a global function with example usage: bucket_with_encryption(sagemaker_session, sagemaker_role) without return types