![How to shutdown SageMaker studio apps automatically?](https://assets.community.aws/a/2gVcboWaFFRBOuqldRUrVzGWD85/AWS_.webp)
How to shutdown SageMaker studio apps automatically?
Amazon SageMaker lacks auto-shutdown for cost control. I'll explain a Terraform based solution to automate app shutdown in this blog.
Published May 15, 2024
While Amazon SageMaker offers a robust suite of features, it lacks native functionality to automatically shut down studio apps when they're inactive, which is crucial for cost control during periods of resource dormancy. In this blog post, I'll elucidate a simple yet effective approach to automatically shutting down studio apps when they're not in use. Leveraging Terraform as our Infrastructure as Code (IAC) tool of choice, we'll walk through the deployment process step by step.
Presented below is a straightforward bash script designed to gracefully shut down apps after a period of inactivity, set to 2 hours by default. Feel free to adjust the timeout duration to suit your specific requirements.
Let's enhance our solution by incorporating a Terraform resource
aws_sagemaker_studio_lifecycle_config
and linking the previously mentioned script within this resource. By integrating a Terraform resource to create the script, we've taken a significant step forward. Now, let's direct this resource to the SageMaker Studio environment, ensuring that all users automatically inherit this configuration by default. This centralized approach simplifies management and guarantees consistent application across the board.
I've also developed a comprehensive Terraform module that orchestrates the creation of essential resources for setting up a SageMaker Studio environment.
Terraform Registry: komminarlabs/sagemaker-studio/aws | Terraform Registry