Skip to content

Setting up an AWS instance with the CBW AMI

Robyn Wright edited this page Jun 24, 2024 · 6 revisions

This page has instructions for setting up an Amazon Web Services instance using the Amazon Machine Image created for the Canadian Bioinformatics Workshops (CBW) in 2024. You can see more information on these workshops on the CBW general pages for the Beginner and Advanced Microbiome Analysis workshops as well as the CBW tutorial pages for the Beginner and Advanced Microbiome Analysis workshops.

To start this, you will need an AWS account.

Please note before starting that using the AWS instances costs money. You can see the associated costs with different types of instances here (note that we are suggesting you use the t2.xlarge instance for this tutorial).

It is therefore really important that you Stop or Terminate the instance when you aren't using it.

Launching an instance

Now, we will launch the image (these instructions are modified from here):

  1. Go to the EC2 console
  2. Choose EC2 Dashboard and then click "Launch Instance".
  3. Under Names and tags, for Name, enter a name for your instance, e.g. "CBW-2024-AMI" (note that it doesn't matter what this is as long as you can identify it)
  4. In Application and OS Images (Amazon Machine Image), search "CBW_MIC_240503". Click on "Select" when this comes up.
  5. In the instance type select "t2.xlarge" - this is the type of instance that we used in the workshop and has 4 vCPU and 16GB memory.
  6. Under Key pair (login), click on "Create new key pair".
  7. Add a name for your key pair (I went with "cbw-2024-ami").
  8. Keep the type as RSA and choose .pem or .ppk depending on where you plan to use this - typically, Mac users will use .pem and Windows users will use .ppk.
  9. Click "Create key pair". This should automatically download the created key pair file - move it to the location on your computer where you want to keep it.
  10. If you will use Mac/Linux then go to the Terminal, navigate to the location of your key pair file and enter the following command: chmod 400 cbw-2024-ami.pem (note: if you gave your key file name a different name, you'll need to modify it in the command)
  11. Now you can choose your existing security group (see below instructions on how to create one).
  12. Now go to Configure storage. You will need to add enough storage here that you can store the CourseData here. For BMB, you should be fine with the default 40GB. As this storage costs money, I recommend first launching an image for BMB with lower storage, and then launching a different one with more storage for AMB. Keep gp3 for both of these.
  13. Now click "Launch instance".
  14. Choose View all instances to check the status of your instance. It may take a few minutes for the instance to launch. Please get in touch if you are unsure.
  15. When the instance has launched, the status will change from "Pending" or to "Running" and the Status check has changed to "2/2 checks passed". This may take a few minutes and you may need to refresh the page. Now you can log in to the instance (see below).

Creating a security group

  1. Open the EC2 console.
  2. In the navigation pane, choose Network & Security > Security Groups.
  3. Choose "Create security group" (top right orange button).
  4. Enter a name for the security group. Amazon recommends that you add the region that you will use to this name. For example, I have been using the US East region and named my group the following: "RW_SG_useast1-cbw_2024-ami". Also add a description to this, e.g. "allow me to access with SSH"
  5. Select the default VPC.
  6. You now have to add some inbound rules so that you will be able to access an instance that you create with this security group. There is guidance on the suggested rules for different use cases here, but I used the following: i. Choose RDP from the drop down list. In source, choose "My IP". Click add rule. ii. Choose SSH from the drop down list. In source click "My IP" - this should automatically add your IP address. Click "Create security group".

Logging into the instance

Assuming that you have followed the above instructions to launch an instance, now you can log into it. This section is modified from the Connect to your Linux instance AWS instructions. We will use the ssh instructions here, but if you wish to do this a different way, please follow the AWS instructions at the link.

Mac

  1. Open a new terminal window.
  2. Log in with the following information:
ssh -i /path/key-pair-name.pem ubuntu@instance-public-dns-name

Your /path/key-pair-name.pem should be the location of your key file and instance-public-dns-name can be found under Public IPv4 DNS in the Instance details. For me, this command looked like this:

ssh -i cbw-2024-ami.pem [email protected]
  1. You may need to type "yes" to say that you want to continue connecting, and then you should see that you have been logged into the instance.

Stopping or terminating the instance

  1. View your active instances.
  2. Select the instance that you have been using and click "Instance state".
  3. Choose "Stop instance" or "Terminate instance" and click "Stop" or "Terminate", respectively.

When you choose to stop the instance, you can restart this at a later time. Note that you will still pay for any storage used, but you won't pay for the use of the instance itself. If you terminate the instance, you will need to go through the same steps as above to make a new instance if you want to come back to this again.

Download all data needed

BMB:

rm CourseData
rm workspace
mkdir CourseData
mkdir workspace
cd CourseData
wget https://hpc4health.ca/cbw/2024/MIC/BMB.tar.gz --no-check-certificate
tar -xvf BMB.tar.gz
rm BMB.tar.gz
mv BMB_data/* .

Now you should be able to start working through the workshop materials, starting with Beginner Module 1.

Clone this wiki locally