Choosing private subnet for SageMaker model deployment


Below is the infra config:

  • 1 VPC with 2 private subnets
  • VPC endpoints configured only to 1 private subnet, say primary subnet (for cost optimization)
  • SageMaker domain configured with same VPC and only the primary subnet
  • All SageMaker jobs containers use the same primary subnet

Issue: SageMaker model deployment function requires 2 private subnets to be provided in the VPC config parameter. We can provide both the subnets under the VPC but want to enforce that the model deployment happens in primary subnets only. Is there a way to provide the preferred subnet id?

Will the below options work:

  • Configure CIDR for secondary subnet in such a way that no more than 1 IP is available and SageMaker can determine the same and do the model deployment in primary subnet only?
  • In the VPC config input parameter, provide the subnets id in the preferred order and SageMaker always picks the first id in the subnets list of the input parameter?

Note: Achieving HA during failover/DR is not necessary here as these model deployments are for trial purposes only.


1 Answer

It seems like SageMaker doesn't let you pick and choose exactly which subnet to use when you've got multiple ones for your deployments. While it's not ideal, SageMaker decides which subnet to deploy based on its internal logic, primarily for availability and operational efficiency.

Unfortunately, there's no straightforward way to specify a "preferred" subnet directly in the setup. People usually just provide a list of subnets, and SageMaker works out the rest. It might seem a bit limiting, especially when you're trying to control your deployment environments closely.

One thing you might think about (though it's a bit of a hack and comes with its own risks) is adjusting the available IPs in your secondary subnet. But, this approach is like walking a tightrope without a net – it's tricky and could lead to other problems.

profile picture
answered 2 months ago
profile picture
reviewed 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions