From the source
Amazon's guide shows how to use a reusable AWS CDK construct with CloudFormation custom resources to deregister and register SageMaker AI endpoint auto scaling automatically during endpoint updates.
- Updating a real-time endpoint's instance type, instance count or environment variables normally fails, because SageMaker AI requires the scalable target to be deregistered first, and once deregistered CloudFormation can no longer track the Application Auto Scaling resources.
- The construct replaces the native ScalableTarget and ScalingPolicy resources with three custom resources ordered by node.add_dependency calls: deregister, the CDK-managed endpoint update, register the scalable target, then attach the scaling policy.
- Register and attach use the CDK provider's asynchronous completion pattern, with is_complete handlers re-invoked every 30 seconds and total timeouts of 1 hour and 15 minutes.
- A ConfigHash property forces CloudFormation to re-invoke the Lambda functions whenever a configuration value changes.
- The deployed stack contains three custom resources, two Step Functions state machines and twelve Lambda functions, seven of them generated by the provider framework.