Quick AWS CLI Tools for Instances I put together

Put together a quick little script to make connecting to instances easier:

(updated the link to the file since I changed the file name)

This script can start the instance and wait for it to be up and running before establishing SSH, and you can also pass a parameter to stop the instance when you beak the SSH connection. Right now the -L localhost:8888:localhost:8888 is baked into the script directly for routing Jupyter to your localhost browser yadda yadda.

This was my procrastination before actually starting Lesson 1, I hope that it might be helpful to other people as well. I wrote up a quick README.md in the folder:

This repo is just my “whatever” repo for vim/bash home scripts and all of that.

@idanbeck This is great! How is the script working out for you? Are you consistently using this every time to connect to the ec2 machine?

1 Like

Yes - this allows me to connect to the instance even if it’s not currently running. Also, passing the -x flag will automatically stop the instance on exit. Usually what I’ll do is I’ll run it once with the instance id pem file and the -x and -s flags to start and top the instance when that ssh connection breaks. In this SSH terminal I’ll boot up jupyter - then I’ll open up another terminal tab (OSX) and connect without the -x and -s flags and use this to do any terminal / ssh stuff I need in the instance. Then when I close the connection of the jupyter one then the instance will automatically shut down (really about saving $$ since I made the mistake of leaving the instance up over night a couple of times and man it was expensive!)