Orchestrating SageMaker AI endpoint auto scaling with AWS CDK
aws ·
Updating Amazon SageMaker AI real-time endpoint configurations via AWS CloudFormation or CDK often fails because SageMaker requires the scalable target to be deregistered before changes are made. However, manual deregistration leads to issues where CloudFormation loses track of auto-scaling resources or leaves stacks in a broken state. To resolve this, the article introduces a reusable CDK construct that automates the deregistration and re-registration process using custom resources. This solution ensures that endpoint updates and auto-scaling parameter changes can occur in a single deployment without manual intervention. The construct employs three custom resources with explicit dependency ordering: one to deregister the target, followed by the endpoint update, and then two asynchronous resources to register the target and attach scaling policies. These asynchronous components use a waiter pattern to ensure the endpoint is fully operational before applying scaling rules. The implementation includes specific logic to handle first deployments and stack deletions gracefully. Users can integrate this construct into existing stacks or deploy it as a standalone example from the provided GitHub repository.
aws