Aws-alias

From Deep Learning Course Wiki
Jump to: navigation, search

The following changes have been made:

  1. In the variable instanceIp, PublicIpAddress has been replaced with PublicDnsName . Either one will work equally well for both ssh and connecting with jupyter notebook - it's largely a matter of taste. In class, Jeremy uses IP address since it's shorter, and he prefers short over long :)
  2. added aws-get-status if at any time you would like to know the status of your instance.
  3. added aws-get-t2-micro - to get instance id if you are running t2.micro
  4. added aws-get-t2-large - to get instance id if you are running t2.large
  5. added aws-switch-2-large - to switch from t2.micro instance to t2.large instance
  6. added aws-switch-2-micro - to switch from t2.large instance to t2.micro instance

To preview the modified (not official) `aws-alias.sh` file please see this link gist


Steps to start and stop using aws-alias

$ source aws-alias.sh
# For a list of alias commands:
$ alias
# To get t2.large instance id(for p2 instance - replace aws-get-t2-large with aws-get-p2):
$ aws-get-t2-large
# To start the instance:
$ aws-start
# To check if your instance is running (at any time):
$ aws-get-status
# This is useful when you would like to see the ip address for your jupyter notebook (which is not started yet)
$ echo $instanceIp
# ssh-into your instance:
$ aws-ssh
# Once you have sshed into your instance:
ubuntu@ip-xx-x-x-xx:~$ jupyter notebook
# Go to a new tab and copy the output of echo $instanceIp and append this string ':8888'
# for example: ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com:8888
# To stop at any time Ctrl-C twice
# To exit ssh:
ubuntu@ip-xx-x-x-xx:~$ logout

and finally and this is a pretty important step

# To stop the instance
$ aws-stop

Other commands

#Example to switch to a t2.large instance from t2.micro instance.
$ aws-get-t2-micro
$ aws-switch-2-large
# To confirm a switch has been made from micro to large
# Should output the instanceId:
$ aws-get-t2-large

# Should output 'None':
$ aws-get-t2-micro