13.2 Network Isolation, VPC Endpoints & Data Encryption
Key Takeaways
- By default, Amazon SageMaker training and inference containers run in an AWS-managed service VPC with internet access; specifying VPC mode attaches Elastic Network Interfaces (ENIs) directly into customer private subnets.
- Enabling EnableNetworkIsolation=True completely disables network interfaces inside the container, preventing external network calls and exfiltration while allowing data ingestion solely via /opt/ml/input and artifact emission via /opt/ml/output.
- AWS PrivateLink Interface VPC Endpoints (sagemaker.api, sagemaker.runtime, ecr.api, ecr.dkr, logs) and Gateway Endpoints (Amazon S3) allow fully private ML workflows without requiring an Internet Gateway or NAT Gateway.
- Data at rest is secured via S3 Server-Side Encryption (SSE-S3, SSE-KMS) and EBS volume encryption (VolumeKmsKeyId), while data in transit is protected via TLS 1.2+ and inter-container traffic encryption (EnableInterContainerTrafficEncryption=True).
- VPC Endpoint Policies and S3 Bucket Policies using condition keys like aws:sourceVpce and aws:sourceVpc enforce strict network perimeters, restricting S3 data access solely to requests originating from authorized private subnets.
Network Isolation, VPC Endpoints & Data Encryption
Securing machine learning workloads against data exfiltration, network eavesdropping, and unauthorized access requires a defense-in-depth architecture. In financial services, healthcare, defense, and enterprise environments, training datasets containing sensitive Personally Identifiable Information (PII) or Protected Health Information (PHI) must never traverse the public internet or be exposed to unmonitored external network connections.
On the AWS Certified Machine Learning Engineer — Associate (MLA-C01) exam, you must demonstrate comprehensive expertise in configuring Amazon Virtual Private Cloud (VPC) network topology for SageMaker, implementing container network isolation, provisioning AWS PrivateLink VPC endpoints, establishing VPC endpoint policies, and enforcing end-to-end encryption across both data at rest and data in transit.
1. SageMaker Network Isolation Architecture
Amazon SageMaker supports three distinct networking modes for running training jobs, processing jobs, and hosting real-time inference endpoints:
+--------------------------------------------------------------------------------------------------+
| SAGEMAKER NETWORK ARCHITECTURE MODES |
| |
| 1. DEFAULT MODE (No VPC Attached) |
| - Compute runs in AWS-managed service VPC. |
| - Internet access enabled via AWS default routes. |
| - Exfiltration risk: Container can make outbound HTTP/HTTPS requests to external IPs. |
| |
| 2. VPC MODE (VpcConfig Attached to Customer Subnets) |
| - SageMaker provisions Elastic Network Interfaces (ENIs) in customer private subnets. |
| - Outbound traffic controlled strictly by customer Security Groups and Route Tables. |
| - Communication with S3, ECR, and CloudWatch flows through customer VPC Endpoints or NAT. |
| |
| 3. NETWORK ISOLATION MODE (EnableNetworkIsolation = True) |
| - Network stack inside the container is completely disabled (no eth0/network interfaces). |
| - Container cannot make ANY inbound or outbound network calls (no internet, no VPC). |
| - Data transfer occurs strictly via filesystem mounts (/opt/ml/input and /opt/ml/output). |
+--------------------------------------------------------------------------------------------------+
Comparing Network Modes
| Feature / Dimension | Default Mode | VPC Mode | Network Isolation Mode |
|---|---|---|---|
| VpcConfig Attached | No | Yes (Subnets + Security Groups) | Optional (Can be combined with VPC) |
| Container Network Stack | Active (Internet enabled) | Active (Routed via VPC) | Disabled (Zero network connectivity) |
| Outbound Internet Access | Yes (AWS network) | Only if NAT Gateway is in route table | No (Impossible from within container) |
| Data Ingestion Mechanism | Direct S3 via AWS | Via S3 Gateway VPC Endpoint or NAT | Pre-mounted by SageMaker to /opt/ml/input |
| Model Artifact Output | Direct S3 via AWS | Via S3 Gateway VPC Endpoint or NAT | Post-uploaded by SageMaker from /opt/ml/model |
| Distributed Training | Supported | Supported | Supported only within local cluster |
| Primary Use Case | Prototyping / Public data | Enterprise private infrastructure | HIPAA / Highly regulated confidential training |
Mechanics of EnableNetworkIsolation=True
When EnableNetworkIsolation is set to True during CreateTrainingJob or CreateModel:
- SageMaker launches the Docker container with all networking capabilities turned off (
docker run --network none). - The training code running inside the container cannot initiate any socket connections, DNS resolutions, or HTTP calls.
- Before container startup, the SageMaker control plane downloads the S3 training data onto the host EBS volume and mounts it into the container at
/opt/ml/input/data/<channel_name>. - When training completes, the SageMaker control plane archives everything written to
/opt/ml/modeland/opt/ml/outputand uploads it to Amazon S3. - This provides a mathematical guarantee that custom algorithm code or third-party open-source libraries cannot transmit proprietary data to unauthorized external servers.
2. AWS PrivateLink & VPC Endpoints for ML
When running SageMaker inside a private VPC with no Internet Gateway and no NAT Gateway (air-gapped private subnet), all communication with AWS services must flow through VPC Endpoints.
+--------------------------------------------------------------------------------------------------+
| PRIVATE VPC ENDPOINT TOPOLOGY FOR SAGEMAKER |
| |
| +------------------------------------------------------------------------------------------+ |
| | CUSTOMER VIRTUAL PRIVATE CLOUD (VPC: 10.0.0.0/16) | |
| | | |
| | +----------------------------------------------------------------------------------+ | |
| | | PRIVATE SUBNET (10.0.1.0/24 - No IGW / No NAT Gateway) | | |
| | | | | |
| | | +--------------------------+ +------------------------------------+ | | |
| | | | SageMaker Training Node | | Interface VPC Endpoints (ENIs) | | | |
| | | | Elastic Network IF (ENI) | -------- | - sagemaker.api (Management API) | | | |
| | | +--------------------------+ | - sagemaker.runtime (Invocations) | | | |
| | | | | - ecr.api & ecr.dkr (Container DL) | | | |
| | | | | - logs (CloudWatch Log Streams) | | | |
| | | | | - kms (Cryptographic Key Ops) | | | |
| | | | +------------------------------------+ | | |
| | | | | | |
| | | v | | |
| | | +--------------------------------------------------------------------------+ | | |
| | | | VPC ROUTE TABLE: Routes 0.0.0.0/0 = Local | pl-12345678 (S3 Prefix) -> vpce | | | |
| | | +--------------------------------------------------------------------------+ | | |
| | +----------------------------------------------------------------------------------+ |
| +------------------------------------------------------------------------------------------+ |
| | |
| v Gateway VPC Endpoint (Free / Route Table Target) |
| +------------------------------------------------------------------------------------------+ |
| | AMAZON S3 (Training Datasets, Checkpoints, Model Artifacts) | |
| +------------------------------------------------------------------------------------------+ |
+--------------------------------------------------------------------------------------------------+
Required VPC Endpoints by Service
- Amazon S3 (Gateway Endpoint):
- Type: Gateway VPC Endpoint (Configured in VPC route tables; free of charge).
- Purpose: High-throughput streaming and downloading of training datasets, feature baselines, and model artifacts.
- SageMaker API & Runtime (Interface Endpoints - PrivateLink):
com.amazonaws.<region>.sagemaker.api: Management API calls (CreateTrainingJob,DescribeModel,CreateEndpoint).com.amazonaws.<region>.sagemaker.runtime: Real-time endpoint invocations (InvokeEndpoint).com.amazonaws.<region>.sagemaker.featurestore-runtime: Low-latency online feature retrieval (GetRecord,PutRecord).
- Amazon ECR (Interface Endpoints - PrivateLink):
com.amazonaws.<region>.ecr.api: ECR API operations (authentication and image metadata).com.amazonaws.<region>.ecr.dkr: Docker image registry data transfer (pulling image layers).
- Amazon CloudWatch Logs (Interface Endpoint - PrivateLink):
com.amazonaws.<region>.logs: Streaming training metrics, standard error, and container stdout.
- AWS KMS (Interface Endpoint - PrivateLink):
com.amazonaws.<region>.kms: Decrypting S3 datasets and generating data keys for EBS volume encryption.
VPC Endpoint Policies & S3 Perimeter Security
To ensure that traffic from your private subnets can only access authorized corporate resources (and prevent malicious actors from exfiltrating data to external S3 buckets using your VPC endpoints), attach a VPC Endpoint Policy to the S3 Gateway Endpoint:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "RestrictToCorporateBucketsOnly",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::corp-training-datasets",
"arn:aws:s3:::corp-training-datasets/*",
"arn:aws:s3:::corp-model-artifacts",
"arn:aws:s3:::corp-model-artifacts/*"
]
}
]
}
Complement this with an S3 Bucket Policy enforcing that data can only be accessed from your specific VPC Endpoint ID (aws:sourceVpce):
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyAccessOutsideDesignatedVPCEndpoint",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::corp-training-datasets",
"arn:aws:s3:::corp-training-datasets/*"
],
"Condition": {
"StringNotEquals": {
"aws:sourceVpce": "vpce-0123456789abcdef0"
}
}
}
]
}
3. Comprehensive Data Encryption Framework
An enterprise ML security architecture requires robust encryption across both data at rest and data in transit.
+--------------------------------------------------------------------------------------------------+
| DATA ENCRYPTION ARCHITECTURAL SPECTRUM |
| |
| DATA AT REST |
| - Amazon S3 Datasets & Models: SSE-S3 (AES-256) or SSE-KMS with Customer Managed Keys (CMKs) |
| - SageMaker EBS Storage Volumes: Encrypted with KMS (VolumeKmsKeyId) |
| - SageMaker Studio Home Storage: Amazon EFS user directories encrypted at rest with KMS |
| - SageMaker Feature Store: Encrypted at rest (Online Store via KMS, Offline Store via S3 KMS) |
| |
| DATA IN TRANSIT |
| - External API & Invocation Requests: Enforced TLS 1.2+ HTTPS |
| - Inter-Container Distributed Training: EnableInterContainerTrafficEncryption = True |
| (Secures node-to-node gradient synchronization across cluster instances via TLS) |
+--------------------------------------------------------------------------------------------------+
3.1 Data at Rest Encryption
- Amazon S3 Storage:
- SSE-S3: Managed by Amazon S3 using AES-256 encryption. Zero additional cost, but lacks granular key access auditing.
- SSE-KMS (Customer Managed Key): Grants complete control over key rotation, IAM delegation, and AWS CloudTrail audit logs.
- S3 Bucket Keys: Enabling S3 Bucket Keys reduces KMS API request traffic from SageMaker by up to 99%, dramatically cutting KMS request costs during distributed training.
- EBS Volume Encryption for Compute Nodes:
- Attached EBS volumes store temporary dataset downloads, local checkpoints, and container swap files.
- By default, EBS volumes attached to SageMaker training and endpoint instances are encrypted with an AWS-managed key. Specify
VolumeKmsKeyIdinCreateTrainingJoborCreateEndpointConfigto enforce encryption with a dedicated CMK.
3.2 Data in Transit & Inter-Container Encryption
In large distributed multi-node training clusters (such as training foundation models or large vision models across 8x ml.p4de.24xlarge instances):
- Training instances continuously exchange multi-gigabyte gradient tensors and parameter updates over the cluster interconnect fabric (such as Elastic Fabric Adapter - EFA).
- Under standard configuration, this inter-node communication occurs over unencrypted internal network connections.
- Setting
EnableInterContainerTrafficEncryption = True(orenable_inter_container_traffic_encryption=Truein the SageMaker Python SDK Estimator) instructs SageMaker to generate an ephemeral self-signed TLS certificate for the cluster and encrypt all inter-node traffic across the network. - Performance Impact: Inter-container encryption introduces a minor compute overhead (typically 5–10% on training throughput), but is strictly required for compliance in PCI-DSS, HIPAA, and military environments.
4. Python SDK Implementation: Secure VPC, KMS & Isolated Training
import sagemaker
from sagemaker.estimator import Estimator
session = sagemaker.Session()
role = "arn:aws:iam::123456789012:role/SageMaker-Secure-ExecutionRole"
# Secure Estimator Configuration
secure_estimator = Estimator(
image_uri="123456789012.dkr.ecr.us-east-1.amazonaws.com/custom-xgboost:latest",
role=role,
instance_count=4,
instance_type="ml.m5.2xlarge",
output_path="s3://corp-model-artifacts/credit-risk/output/",
sagemaker_session=session,
# 1. Volume Encryption with Customer Managed Key
volume_kms_key="arn:aws:kms:us-east-1:123456789012:key/cmk-ebs-ml-key",
# 2. Output Artifact KMS Encryption
output_kms_key="arn:aws:kms:us-east-1:123456789012:key/cmk-s3-ml-key",
# 3. Customer VPC Subnet and Security Group Attachment
subnets=["subnet-0a1b2c3d4e5f6g7h8", "subnet-0b2c3d4e5f6g7h8i9"],
security_group_ids=["sg-0123456789abcdef0"],
# 4. Total Container Network Isolation (No external socket calls)
enable_network_isolation=True,
# 5. Distributed Multi-Node Inter-Container Traffic Encryption
encrypt_inter_container_traffic=True
)
[!TIP] Exam Rapid Decision Rules:
- If the question requires preventing training/inference containers from making any outbound network calls or exfiltrating data $\rightarrow$ Set
EnableNetworkIsolation=True.- If the question asks how to run SageMaker in a private VPC with no internet access $\rightarrow$ Provision a Gateway VPC Endpoint for S3 and Interface VPC Endpoints for ECR (
ecr.api,ecr.dkr), SageMaker (sagemaker.api), and CloudWatch (logs).- If the question mandates encrypting inter-node gradient exchanges during distributed training $\rightarrow$ Enable
EnableInterContainerTrafficEncryption=True.- If the question asks how to restrict S3 bucket access strictly to queries from a private VPC $\rightarrow$ Use an S3 Bucket Policy with
Condition: { "StringNotEquals": { "aws:sourceVpce": "<vpce-id>" } }.
A healthcare enterprise is building a custom computer vision model on Amazon SageMaker using sensitive diagnostic imagery subject to strict HIPAA regulations. The security compliance officer mandates that the container running the training algorithm must be completely prevented from communicating with external IP addresses or third-party web services to eliminate data exfiltration risks, while still allowing the container to consume training images from Amazon S3 and write model checkpoints. Which configuration satisfies this requirement with the lowest operational overhead?
An ML engineer is launching a distributed multi-node PyTorch training cluster across 8 ml.p4de.24xlarge GPU instances in a private VPC subnet. Corporate compliance policy mandates that all data exchanged between cluster nodes during distributed gradient synchronization and tensor reduction must be encrypted in transit. Which configuration must the engineer implement?
A defense contractor needs to configure a completely isolated private VPC environment for SageMaker Studio and batch model training jobs. The VPC has no Internet Gateway, Virtual Private Gateway, or NAT Gateway. The training jobs must download training datasets from Amazon S3, pull custom Docker container images from Amazon ECR, and write execution log events to Amazon CloudWatch Logs. Which set of VPC endpoints must be created in the VPC to support this workload?
A security team wants to ensure that proprietary training datasets stored in an Amazon S3 bucket (s3://enterprise-ml-data/) cannot be accessed from outside the company's designated VPC, even if an IAM credential is leaked to an external entity. Which access control mechanism and condition key should be configured to enforce this perimeter constraint?