'Shutdown AWS Sagemaker without using Python script

I am trying to find a solution to auto shutdown AWS Sagemaker instance after 1 hour of idleness. I found the below solution for this but at our environment the Sagemaker cant access any code from internet so wget will fail. Is there any way to achieve this result without using the script from below solution? Like defining everything in the bash shell and then run it using cron job?

https://github.com/aws-samples/amazon-sagemaker-notebook-instance-lifecycle-config-samples/blob/master/scripts/auto-stop-idle/on-start.sh



Solution 1:[1]

If you're using SageMaker Studio you can use sagemaker-studio-auto-shutdown-extension to auto shutdown instances without requiring internet access. Reference this AWS blog post for more info

Solution 2:[2]

If internet access is the only blocker, you can save the file to a location in s3 and then replace wget line with -

aws s3 cp s3://bucket/prefix/autostop.py .

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pirateofebay
Solution 2 durga_sury