# AWS EC2 Instance

Previously we recommended that Windows users use Pushkin through an AWS EC2 instance due to bugs in WSL that made the setup unreliable. This issue seems to have been resolved, so we now recommend using WSL instead of an EC2 instance. Using an EC2 instance has a number of limitations, including:

* You cannot do true local testing via `localhost`, as the IPv4 public IP address must be used.
* In our experience, timeout errors are more common on EC2 instances.
* If multiple experiments are installed, the EC2 instances may run out of space with the default amount of storage.

However, users can choose to create a free-tier [Amazon Web Services (AWS) EC2](https://aws.amazon.com/ec2/) instance for using and deploying Pushkin as an alternative to using WSL on Windows. In your instance, you will be able to run an Ubuntu virtual machine and follow the Ubuntu setup instructions. We suggest accessing this AWS EC2 instance from your local computer using the [PuTTY SSH client](https://www.chiark.greenend.org.uk/~sgtatham/putty/), though in principle any SSH client for Windows should work.

## Skip to section

* [Create your AWS EC2 instance](#create-your-aws-ec2-instance)
* [Install and configure PuTTY](#install-and-configure-putty)
* [Connect to your EC2 instance](#connect-to-your-ec2-instance)
* [Managing your AWS instance](#managing-your-aws-instance)
* [Next steps](#next-steps)

### Create your AWS EC2 instance

#### Create your AWS Account

Go to [Amazon Web Services](https://aws.amazon.com/free/) and click _Create a free account_.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-69dfff0745dcf6264da5c3d5bb1f62804ae3f3a2%2F1%20\(1\).gif?alt=media)

Complete the sign-up process and go to your inbox to confirm your email address.

#### Launch your EC2 Instance

Head to the [AWS EC2 console](https://console.aws.amazon.com/ec2/v2/home) and, in the left sidebar, click _Instances_.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-5e16db3c5db3cf50b13546fced59a35a37c800a2%2F2%20\(1\).gif?alt=media)

Click on the _Launch Instance_ button.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-4231d4a1367ba9e15b5766fc1b6e841c53b2b236%2F3%20\(1\).gif?alt=media)

Scroll down to the **Application and OS Images (Amazon Machine Image)** and under the **Quick Start** tab and click on Ubuntu. The default selected should say _Free tier eligible_, but if it doesn't, click on the box and select a version that is free.

Now, scroll down to the **Key pair (login)** option, and on the bottom right, click on **Create new key pair**, create a new key pair and give it a name, (e.g., "pushkin-testing-key"), set it to **RSA** key type and change the private key format to **.ppk**. **Make sure to dowload this file, keep it somewhere as this will be necessary to connect your instance later**

Next, on the right of the **Network settings** heading, select _Edit_.

Select _Add security group rule_, under _Type_, choose **HTTP** in the drop-down menu. Then, select _Add rule_ again and, under _Type_, select "HTTPS".

Now, click on **Launch Instance**.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-ed2fa953d31b3791f3fb3f5413d74a10f2ec17ff%2F9%20\(1\).gif?alt=media)

Next, in the box that says "Your instances are now launching," click the instance ID, which will be an alphanumeric string.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-efcc4c5cf69a66d6c5b187e5ff4c19a17f089c7d%2F10%20\(1\).gif?alt=media)

This will take you to the AWS EC2 console. You should keep this window open.

### Connect to your EC2 instance

In the Windows start menu, open **PuTTY**.

In the **Category** pane, choose **Session**.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-c6e6e09a113a0a0f3ec0870b7d20fc7f15ef576b%2F16%20\(1\).gif?alt=media)

In the _Host Name_ box, enter "ubuntu@" followed by the public DNS of your instance.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-a1a93a6f5e20b3785f8048bcca3ed96d204e22d2%2F17%20\(1\).gif?alt=media)

The public DNS is found on the AWS EC2 console. One example is "ec2-18-191-193-31.us-east-2.compute.amazonaws.com". The 2- and 3-digit numbers will be different for each instance and "us-east-2" is based on what region you are in.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-6c295255b34cf89709cbc41120566403949fe902%2F13%20\(1\).gif?alt=media)

Ensure that the _Port value_ is **22**, the under _Connection type_ select **SSH**.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-bbd152af70fa6c397cb3dcdb9ab8d12c2b1a3e3b%2F18%20\(1\).gif?alt=media)

In the Category pane, expand **Connection**, expand **SSH**, expand **Auth**, then choose **Credentials**.

Select the ".ppk" file you generated for your key pair and choose **Open**.

If you plan to start the session again later, you can save the session information. Under _Category_, choose **Session**, enter a name for the session in _Saved Sessions_, and then choose **Save**.

**Note:** When you stop running the AWS instance from the AWS console, on restart the IP address and the Public DNS will be different. If you save your settings in PuTTY, you will need to replace part of your host name with the new IP address. All other saved settings remain the same.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-cd7086b53eada5428924248218d7195d9f81c6d0%2F21%20\(1\).gif?alt=media)

You can now choose **Open** to connect to your instance. PuTTY will display a security alert dialog box asking if you trust the host you are connecting to: choose **Yes**.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-31e6e33881af8cfc09ef61823e8db5865f4afec4%2F22%20\(1\).gif?alt=media)

You are now connected to your instance! In the window that appears, run the following commands to update your Ubuntu EC2 instance:

```bash
 sudo apt update
 sudo apt upgrade
```

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-68ab27bbc0a284b0bbdc60cc7a9e6c764a762504%2F34.gif?alt=media)

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-6969055700ee345227d7655c4992033749c622e0%2F35.gif?alt=media)

While upgrading, a box may come up that says the following:

```
A new version of /boot/grub/menu.lst is available, but the version installed currently has been locally modified.
```

Use the UP arrow key to select `install the package maintainer's version` and press ENTER to continue.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-cc16b174c09b20fc37aecb829921f0562eb390ee%2F30.gif?alt=media)

(For more on package management with apt, you can see the documentation [here](https://ubuntu.com/server/docs/package-management). To learn more about the basics of the Linux command line, you can follow [this tutorial](https://ubuntu.com/tutorials/command-line-for-beginners#1-overview).)

### Managing your AWS instance

#### Remember to stop your instance

To avoid incurring charges on AWS's Free Tier, always shut down your AWS EC2 instance when you're done using it. To do this, go to the AWS EC2 console, right-click on your instance, expand _Instance State_, and select **Stop**. When a dialog box appears, click **Yes, Stop**.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-6e41cc4056978a27f70ec39139e2274b4bbdac42%2F33.gif?alt=media)

#### How to restart your instance

To restart your instance, go to the AWS EC2 console, right-click on your instance, expand _Instance State_, and select **Start**.

![](https://2413710172-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MBpE95WB58asBviCj30%2Fuploads%2Fgit-blob-187f82483bed019d1f90a804bb1e66299832e242%2F32.gif?alt=media)

### Next steps

From here, you can follow the instructions for [Ubuntu Linux](../ubuntu-install) to finish the installation.
