To get started on amazon EC2 using UCSD's allocation.
How to use Amazon EC2
Amazon EC2 is a cloud based IAAS - Infrastructure as a Service - platform. Your CSE260 account has been preallocated a limited amount of resources to use on EC2 (varies quarter to quarter).
Depending on the machine type, EC2 resources are charged at different rates. There is one rate for computation and another for storage. When your instance is running, you will be charged the compute rate. Unlike normal amazon accounts which are charged in increments of one hour, your account will be charged in 1 second increments with a minimum one-minute charge. Its important to stop your instance when you are not using it so you don't accrue useless charges. When your instance is "STOPPED", your files will remain in the elastic block store (EBS) file system attached to your instance There is a small charge for this so your account balance will gradually decrease.
If you are running low on funds, please let us know.
Note, the t2.micro (x86) instances are burstable instances - they guarantee 10% of the CPU's performance and allow burst performance of 100%. The time spend at 100% is throttled by CPU credits, which are accrued at 6 CPU credits/hour. I hadn't noticed this throttling effect when i did some tests on EC2, but you may - please let us know your feedback on this.
In contrast, EC2 also offers fixed performance instances (e.g. M3, C3, R3). Note: m3.medium is a fixed performance instance and costs ~0.077/hour which is pretty low.
https://aws.amazon.com/ec2/instance-types/#burst
In this example, we'll show you how to create an instance for Assignment #1. There will be similar procedures for assignment #2 (and possibly #3).
1) Use the following link (sign in with UCSD Active Directory Credentials): https://awsed.ucsd.edu/ .
First, click the class "CSE260_FA24_A00"; on the next page, click the role "CSE260_FA24_A00_student". And you will be directed to AWS website.
2) Select "Instances" from the left panel and then "Launch Instances" (the yellow button).
3) Name the instance carefully.
The highly recommended format is: 'cse260-fa24-<repo_name>'
The 'cse260-fa24' should help organize the instance list since you will see instances from all around UCSD.
But if you forget to, you can do it later. Just click on the "Name" field and name it exactly the same as the name of your git repo for the corresponding assignment.
4) In the option to browse more AMIs, search for AMI #0061a99e0a77d083b. In the 'My AMIs' tab select the (ONLY) AMI.
5) Select your machine type. For assignment #1, we will use c7g.medium.
WARNING: you must select this exact type. AWS budget isn't the biggest deal. Since the performance bar in GFlops is machine/CPU -specific, using a different one can cause you unnecessary trouble.
After selecting the machine type, click "Review and Launch".
6) Create a new key pair and make sure to use the EDA25519 option.
7) Now set the security group (click on the "Select an existing security group" option).
8) UCSD has set up some special security groups to allow "Inbound from UCSD Campus Hosts Only". Select that one for the most security. If you need SSH access outside the campus network, either use the campus VPN or choose the SSH+XXX Global.
9) Finally, "Launch".
10) After a little while, the instance will launch. Click on "View all Instances".
11) connect the instance. Use the check box on the left to select your instance and then use the "Connect" button on top
12) Copy and paste the "Example" ssh line, BUT change "root" to "ubuntu", to a window on some machine logged on the UCSD network (You may need to connect via VPN if the ssh request times out on certain networks). Make sure that the machine has your .pem file on it, and you point to that file (might need to include the entire file path depending on where you ssh from). You may need to ensure the key is publicly viewable as instructed in AWS.
The command should look like this:
ssh -i "b5chin-cse260-fa24.pem" ubuntu@ec2-52-25-155-148.us-west-2.compute.amazonaws.com
Alternatively, you may want to look at this class page and set SSH up in your code editor, because that gives you a way easier life during actual development.
13) Potential SSH error
If you forget the step 3 in the "Connect to instance" screenshot above, you may get a super long error when trying to SSH. These lines (on Windows) tell you the reason.
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> @ WARNING: UNPROTECTED PRIVATE KEY FILE! @
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> Permissions for '<path to your pem key file>' are too open.
> It is required that your private key files are NOT accessible by others.
> This private key will be ignored.
For those with Linux and Mac as their host OS, that chmod command should suffice. For windows users, it's a little tricky. There are numerous resources on the Internet, and it's a perfect opportunity to learn something on your own through searching, asking AI, office hours, and/or talking to your classmates.
In the end, Windows users should see the following:
Right click the .pem key file -> Properties -> Security tab; your username should be the only entry in the "Group or user names" box. And in the box below, the only permission you have should be READ.
From the view instance window, select Actions->Instance State-> Stop
An instance that is not running, still consumes resources. While it is not assigned a CPU, it is assigned storage. If you no longer need your instance you can terminate your instance. This will remove all storage associated with your instance so make sure you have saved what you need elsewhere before you do this (e.g. make sure you have checked in everything to github).
If a student wishes to terminate their instance, they first need to go to the *already running*
instance's tags, click "Manage tags" and > then add
a new tag named "terminable". For the tag's value, they need to set it to "true".
If they do that, they should then be able to terminate their
instance without issue.