logo
Menu
How to shutdown SageMaker studio apps automatically?

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

Introduction

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.

The script

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.

How to deploy this script using terraform?

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.

A complete Terraform module to deploy and manage SageMaker.

I've also developed a comprehensive Terraform module that orchestrates the creation of essential resources for setting up a SageMaker Studio environment.

Comments