Configuring Cloud9 for Remote Development

Indie Campers Tech Blog
Indie Campers Tech Journey
7 min readApr 28, 2022

Hello, my name is Marco Bomfim and I’m a Full-stack Engineer here at Indie Campers. We are a company with several remote engineers, which means that we also have different environments to work in. I, for instance, use a Windows PC to work, while other people may be using a Linux distro or a Mac.

Having so many different environments leads us to search for a way of unifying those. We know that Docker is a way to achieve this common ground between environments, although, in my case, I had some issues with WSL (The Linux subsystem for Windows) due to too much memory and disk allocation, which could lead to some unexpected behaviours like the machine turning off, or freezing. So… What can we do?

Here at Indie, we decided to try out some remote development environments and went with Cloud9 since we are already using AWS, and we could manage instance access without the need to configure a new VPC or any other security rules and this guide is for you that want to know how to:

  1. Get a Cloud9 instance running
  2. Allowing SSH access from outside of your AWS infrastructure
  3. Connecting to your instance from VSCode, or any other tool that supports SSH

What is Cloud9

Cloud9 is a cloud environment for development. In simple terms what it does is: it creates an EC2 instance, and configures all the security rules, port-forwarding, as well as a cloud-based IDE that you can use. Some companies and even Harvard’s CS50 course use Cloud9 since it provides you with the ability to create custom Images and machines for your employees/students, without leaving the configuration burden to them, and can be accessed from basically any device.

Creating a new Cloud9 Instance

Creating a new Cloud9 instance is pretty straightforward. First of all, let’s access our AWS Dashboard, and search for Cloud9.

At the Cloud9 Dashboard, we’re going to Create environment:

Step 1

Now we’re going to define the details and configuration of our environment, the first part of the form is to tell AWS what is the Name and Description of your instance. A tip for companies that have a lot of EC2 instances running: make sure to put a meaningful name to your instance so it’s easier to find when searching for it on the EC2 dashboard.

Step 2

Now that we have our instance name and description, is time for configuring the machine itself. In this blog post we are only going to follow the basic workflow, but if you’re curious about more configuration options, make sure to check out the documentation provided on the form itself.

To configure the instance, we’ll have to define some settings. Below you can see what I’ll be using in this guide, but make sure to adapt to your needs:

  • Environment Type
  • Create a new EC2 instance for environment (direct access)
  • Instance Type (the EC2 machine you’re rolling with)
  • m5.large (8 GiB RAM + 2 vCPU)
  • Platform (the distro of the instance)
  • Ubuntu Server 18.04 LTS — you can also use Amazon’s distros, which are customized.
  • Cost-saving settings (this CANNOT be changed afterwards)
  • I’ve chosen to stop the instance after a day
  • Network Settings (if your company has custom VPCs and Subnets on AWS)
  • We’re using the default on this post, but feel free to choose any VPC and Subnet that you desire.

Step 3

Now is the time to review your environment, and if everything is in order, just scroll down and hit Create Environment.

Customising the created environment

Once the creating is done, you’ll be presented with the cloud-based IDE.

Here, you can do whatever you want. Imagine this is a VSCode, but on your browser. Before we continue there are some things I like to do in order to avoid issues in the future, so in this step, we are going to:

  1. Allow SSH access to the instance
  2. Increase the instance’s storage volume

Allowing SSH Access

In order to allow SSH access, there are some steps we need to follow, we’ll start by adding our SSH key to the instance:

  1. First of all, we’ll have to create a new SSH key on your local machine, so we can use it on our Cloud9.
  2. If you don’t know how to do this, you can follow this guide on GitHub
  3. Now that we have the key, we’ll need to tell our Cloud9 instance to accept it. To do this, you’ll have to edit the ~/.ssh/authorized_keys file on our instance, and add your newly generated SSH public key to the end of the file, like so:

Now that we have our key added to the instance, it’s time to allow SSH access on the EC2 machine, to do so, we’ll have to update our Incoming Security Rules, to do so we’ll have to:

  1. On the top-right corner of your Cloud9 IDE, click on the round button with your initials, then click on Manage EC2 Instance
  2. You’ll be redirected to the EC2 Dashboard, once here, click on the checkbox next to your instance’s name, and the Details panel will open.
  3. Under Security click on the Security Group ID, to open it
  1. Now, click on Edit Inbound Rules
  2. Click Add Rule
  3. Under Type, choose SSH
  4. And in Origin, choose My IP Address
  5. Save the rules

And now you should be able to ssh into your instance from your local machine. But before we do this, let’s first increase our instance’s volume so we don’t get a full hard drive when installing our dependencies on our project.

Increasing the instance volume

To do this, let’s go back to our EC2 Dashboard and select our instance. Now we can:

  1. Click on Storage under the Instance details
  2. Click the volume ID (looks something like this vol-0a0a0a0a0a0)
  3. On the Volumes Dashboard, select your volume like you did for your EC2 instance
  4. Now, on the top-right corner, click on Actions > Modify Volume
  5. Change the size of the instance to something larger. I’m going to use 50GB.
  6. Click Modify

Now, go back to your EC2 Dashboard, and select your instance, and under Instance State, select Reboot.

Develop using VSCode

With all of this out of the way, we are good to connect our VSCode to this instance. To do so, we first need to install an extension on VSCode called:

Once installed, you can do the following:

  1. Hit CTRL + SHIFT + P and look for “Open SSH Configuration File”
  1. Inside this file, populate the file with the following, remember to add your EC2 instance IP, and the path to your SSH file:
    1 Host put-anything-here
    2 HostName <EC2 Public IP here>
    3 User <'ubuntu' if on Ubuntu 18, AWS Linux should be 'ec2-user' or 'root'> 4 IdentityFile path/to/ssh/key
  2. Save the file and hit CTRL + SHIFT + P then type Connect to Host
  3. Select the Host you’ve configured (the Host property on the SSH config is the name that will appear here)
  4. Accept the connection, and you’re now connected to your Cloud9 environment.

Wrapping up

That’s all there is to it, now you will have a running instance, with a Linux distro running, and VSCode also does the port-forwarding automatically for you so you can access your Cloud9 instance as localhost.

There are some things to consider though:

  • It’s possible to allow other users to connect to the public IP address or DNS of your EC2 instance by configuring the TCP port of your running application to allow all IP addresses or another person’s IP address, this allows other users to test your applications WHILE you’re still developing them.
  • Depending on the region of your instance, there may be a certain delay (I get around150/200ms from Brazil to Ireland). You’ll only feel this delay on the terminal or any operation that requires you to fetch files remotely. When editing on VSCode buffers, you won’t have any issues.
  • VSCode session seems to be ignored by Cloud9, so the Cost-Savings configuration will shut down your instance even if you’re active on it.
  • Once the instance is shut down, the IP changes, unless you have a static IP from a custom VPC. If the IP changes, don’t forget to update your VSCode SSH configuration with the new IP
  • If you’re not able to connect to the instance and have no idea why check if perhaps your IP address hasn’t changed. If so, update your security rules again with the new IP.

--

--

Indie Campers Tech Blog
Indie Campers Tech Journey

Learn more about the Indie Campers Tech & Product team and how we design and build our product