AWS Security ChangesHomeSearch

AWS sagemaker documentation change

Service: sagemaker · 2026-06-28 · Documentation low

File: sagemaker/latest/dg/adapt-training-container.md

Summary

Updated SageMaker training code examples from Estimator to ModelTrainer class, added new SDK v3 examples, and modified deployment/prediction code

Security assessment

Changes involve SDK class/method renaming (Estimator→ModelTrainer) and code structure updates. No security vulnerabilities, patches, or security feature documentation are mentioned. The IAM role reference remains unchanged with no security modifications.

Diff

diff --git a/sagemaker/latest/dg/adapt-training-container.md b/sagemaker/latest/dg/adapt-training-container.md
index 1827c4f3d..e93474a60 100644
--- a//sagemaker/latest/dg/adapt-training-container.md
+++ b//sagemaker/latest/dg/adapt-training-container.md
@@ -41 +41 @@ SageMaker AI creates an IAM role named `AmazonSageMaker-ExecutionRole-`YYYYMMDD`
-  6. In the **Permissions and encryption** section, copy **the IAM role ARN number** , and paste it into a notepad file to save it temporarily. You use this IAM role ARN number later to configure a local training estimator in the notebook instance. **The IAM role ARN number** looks like the following: `'arn:aws:iam::111122223333:role/service-role/AmazonSageMaker-ExecutionRole-20190429T110788'`
+  6. In the **Permissions and encryption** section, copy **the IAM role ARN number** , and paste it into a notepad file to save it temporarily. You use this IAM role ARN number later to configure a local training ModelTrainer in the notebook instance. **The IAM role ARN number** looks like the following: `'arn:aws:iam::111122223333:role/service-role/AmazonSageMaker-ExecutionRole-20190429T110788'`
@@ -152 +152,19 @@ Remember that `docker` looks for a file specifically called `Dockerfile` without
-  2. Paste the following example script into the notebook code cell to configure a SageMaker AI Estimator.
+  2. Paste the following example script into the notebook code cell to configure a SageMaker AI ModelTrainer.
+
+SageMaker Python SDK v3
+    
+    
+        import sagemaker
+    from sagemaker.train import ModelTrainer
+    from sagemaker.train.configs import Compute
+    from sagemaker.core.helper.session_helper import get_execution_role
+    
+    model_trainer = ModelTrainer(training_image='tf-custom-container-test',
+                          role=get_execution_role(),
+                          compute=Compute(instance_count=1,
+                                          instance_type='local'))
+    
+    model_trainer.train()
+
+SageMaker Python SDK v2 (Legacy)
+    
@@ -164 +182 @@ Remember that `docker` looks for a file specifically called `Dockerfile` without
-In the preceding code example, `sagemaker.get_execution_role()` is specified to the `role` argument to automatically retrieve the role set up for the SageMaker AI session. You can also replace it with the string value of **the IAM role ARN number** you used when you configured the notebook instance. The ARN should look like the following: `'arn:aws:iam::111122223333:role/service-role/AmazonSageMaker-ExecutionRole-20190429T110788'`. 
+In the preceding code example, `get_execution_role()` is specified to the `role` argument to automatically retrieve the role set up for the SageMaker AI session. You can also replace it with the string value of **the IAM role ARN number** you used when you configured the notebook instance. The ARN should look like the following: `'arn:aws:iam::111122223333:role/service-role/AmazonSageMaker-ExecutionRole-20190429T110788'`. 
@@ -239 +257 @@ If this error occurs, you need to attach the **AmazonEC2ContainerRegistryFullAcc
-  3. Use the `ecr_image` retrieved from the previous step to configure a SageMaker AI estimator object. The following code sample configures a SageMaker AI estimator with the `byoc_image_uri` and initiates a training job on an Amazon EC2 instance.
+  3. Use the `ecr_image` retrieved from the previous step to configure a SageMaker AI ModelTrainer object. The following code sample configures a SageMaker AI ModelTrainer with the `byoc_image_uri` and initiates a training job on an Amazon EC2 instance.
@@ -245,2 +263,3 @@ SageMaker Python SDK v1
-    from sagemaker import get_execution_role
-    from sagemaker.estimator import Estimator
+    from sagemaker.core.helper.session_helper import get_execution_role
+    from sagemaker.train import ModelTrainer
+    from sagemaker.train.configs import Compute
@@ -248 +267 @@ SageMaker Python SDK v1
-    estimator = Estimator(image_uri=byoc_image_uri,
+    model_trainer = ModelTrainer(training_image=byoc_image_uri,
@@ -250 +269 @@ SageMaker Python SDK v1
-                          base_job_name='tf-custom-container-test-job',
+                          compute=Compute(
@@ -252 +271,2 @@ SageMaker Python SDK v1
-                          instance_type='ml.g4dn.xlarge')
+                              instance_type='ml.g4dn.xlarge'),
+                          base_job_name='tf-custom-container-test-job')
@@ -255,2 +275 @@ SageMaker Python SDK v1
-    estimator.fit()
-    
+    model_trainer.train()
@@ -263,2 +282,3 @@ SageMaker Python SDK v2
-    from sagemaker import get_execution_role
-    from sagemaker.estimator import Estimator
+    from sagemaker.core.helper.session_helper import get_execution_role
+    from sagemaker.train import ModelTrainer
+    from sagemaker.train.configs import Compute
@@ -266 +286 @@ SageMaker Python SDK v2
-    estimator = Estimator(image_uri=byoc_image_uri,
+    model_trainer = ModelTrainer(training_image=byoc_image_uri,
@@ -268 +288 @@ SageMaker Python SDK v2
-                          base_job_name='tf-custom-container-test-job',
+                          compute=Compute(
@@ -270 +290,2 @@ SageMaker Python SDK v2
-                          instance_type='ml.g4dn.xlarge')
+                              instance_type='ml.g4dn.xlarge'),
+                          base_job_name='tf-custom-container-test-job')
@@ -273 +294 @@ SageMaker Python SDK v2
-    estimator.fit()
+    model_trainer.train()
@@ -279,0 +301 @@ SageMaker Python SDK v2
+    import json
@@ -282 +304,3 @@ SageMaker Python SDK v2
-    from sagemaker import image_uris
+    from sagemaker.core import image_uris
+    from sagemaker.serve import ModelBuilder
+    
@@ -287 +311,8 @@ SageMaker Python SDK v2
-    predictor = estimator.deploy(1,instance_type='ml.g4dn.xlarge',image_uri=container)
+    model_builder = ModelBuilder(
+        image_uri=container,
+        s3_model_data_url=model_trainer.model_data,
+        role_arn=get_execution_role(),
+        instance_type='ml.g4dn.xlarge'
+    )
+    model = model_builder.build()
+    endpoint = model_builder.deploy()
@@ -310 +341 @@ Convert the test handwritten digit into a form that TensorFlow can ingest and ma
-        from sagemaker.serializers import JSONSerializer
+        import json
@@ -312,2 +343,2 @@ Convert the test handwritten digit into a form that TensorFlow can ingest and ma
-    predictor.serializer=JSONSerializer() #update the predictor to use the JSONSerializer
-    predictor.predict(data) #make the prediction
+    response = endpoint.invoke(body=json.dumps(data))
+    result = json.loads(response.body.read().decode('utf-8')) #make the prediction