Installing the Heroku CLI on AWS Sagemaker Studio Lab

Austin Lasseter
3 min readJun 13, 2022

Together, SMSL and Heroku make a powerful (and free!) combination that makes it easy to develop and deliver machine learning applications.

  • Amazon SageMaker Studio Lab (SMSL) is a free machine learning (ML) development environment that provides the compute, storage (up to 15GB), and security — all at no cost — for anyone to learn and experiment with ML! It’s a real game changer for ML students and enthusiasts.
  • Heroku is a cloud platform that lets developers build, deliver, and scale their apps — bypassing infrastructure headaches and focusing on deploying our apps to end-users.

While it’s possible to deploy on Heroku directly from Github, the optimal form of deployment is to use the heroku CLI. It provides a more secure and seamless CI/CD workflow than using the GUI interface, and it eliminates the need for using Github as a middle-man. The Heroku CLI also provides easy access to log files, which are an essential part of troubleshooting and bug-fixing.

Installing the Heroku CLI on SMSL is not quite as straightforward as installing it on your personal Macbook or Linux device, because the SMSL Linux kernel doesn’t currently support sudo apt. This blog post provides some workarounds to get you up and running in no time.

Open up a terminal session in SMSL. Navigate to the highest level folder (whic should be \home\studio-lab-user ) — you can get to it with cd ~— and run the following Linux commands:

wget https://cli-assets.heroku.com/heroku-linux-x64.tar.gz
tar --ungzip -xf heroku-linux-x64.tar.gz
rm heroku-linux-x64.tar.gz

This will retrieve the Heroku CLI installation code as a tarball file, extract and install it in a new directory called heroku, then delete the tarball. Add Heroku to path as follows. Note that the .bashrc file is not persistent across SMSL sessions. You’ll have to repeat these two lines of code every time you open a session with your SMSL runtime.

echo "export PATH=\$PATH:~/heroku/bin" >> ~/.bashrc
source ~/.bashrc

Log in to Heroku:

heroku login -i

This will open a prompt where you’ll need to enter your Heroku username and password, like this:

heroku: Enter your login credentials
Email: austinlasseter@gmail.com
Password: ************
Logged in as austinlasseter@gmail.com

All in all, it should look something like this:

Note that Heroku offers the option for multi-factor authentication (read the docs here). If you choose to use MFA, then you won’t be able to use your regular password when logging in via CLI in the SMSL terminal. This is because SMSL doesn’t have a browser. However, you can work around this by generating an API key in Heroku, and then pasting that instead of your password. More info here and here.

Once you’re logged in, you can start creating your first application with the simple command

heroku create

But to explore app creation, please go ahead and read my full blog post on that topic. Happy programming to you!

--

--