Development on a Cloud machine

After a quick preliminary search I found that I could use Visual Studio Code locally and automate everything through the task concept that Visual Studio Code utilizes. I switched to AWS Cloud 9 and that clicked for me in a way that maybe I could have gotten from Visual Studio Code as well with more experience.

Over all I am pretty satisfied with both approaches and I selected AWS Cloud 9 for now. I think working with the IDE for a bit will show me a few more strengths and customization options.

Let me run through some of the common elements that I used when setting up both solutions.

Installation

Installation in both cases is a simple task where direct support is available and ample, both require launching a virtual machine with AWS Cloud 9 that machine is actually installed in one go with everything else. For the regular EC2 instance I need to manage my pem certificate myself, with the AWS Cloud 9 solution that is automagically done with my login.

Visual Studio Code requires an extension to use the EC2 instance as its filesystem. That extension is conveniently called SSH FS.

The SSH FS configuration for my EC2 instance looked like this:

"sshfs.configs": [ {
"name": "Aypahyo_EC2",
"root": "~/",
"host": "ec2-18-194-10-20.eu-central-1.compute.amazonaws.com",
"port": 22,
"username": "ec2-user",
"privateKeyPath": "C:/AWS/AWS_Aypahyo_DevMachine.pem",
}]

In retrospect it may be useful to mount one filesystem per project since the root folder of the workspace matters.

Code and Compile

I wrote a simple C++ program with a makefile for both options. Visual Studio Code makes you download an extension for C++ as a basis for all tasks, In AWS Cloud 9 languages are preinstalled and can compile out of the box. I disliked that Cloud9 does that, I could not tell what compiler options were used nor which compiler was at play.
In both versions it is possible to define your own runners or tasks respectively and that is what I ended up doing.

To compile and run I created an sh script on the server side that uses docker compile to compile my makefile project. Docker was properly installed on the AWS Cloud9 machine, somehow I had to install it on my EC2 instance that I used for Visual Studio Code.

docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp gcc make

Compiling using docker means that your output is on the console so it needs to be parsed in order to tell if an error happened. I was able to set that up in Visual Studio Code and very conveniently the relevant files for that end up in the repository meaning that they would be shared with future me on another machine. the error report showed up in the error log and was clickable – however visual studio code could not find the correct file based on the reported filename. I could not tell why and I assume it is some conflict with the SSH FS plugin. In Cloud 9 I could not find any form of error window and was unable to configer that.
With both solutions I am not sure how debugging would be integrated with my docker compile choice.

Source Control

When it came to git integration Visual Studio Code just did not show GIT as an option although everything comes pre installed with that package. My assumption here is that it would show if visual studio code would detect the .git folder on my system. Since the connection to my files ran through the extension SSH FS I assume Visual Studio Code could not prosperly inspect the files on the remote machine. In that sense git behaved just the same with both machines where the git commands had to be entered on an ssh terminal. The only difference here is that the SSH terminal connection had to be set up on my machine for the visual studio code solution to work where as in the AWS Cloud 9 solution the connection is part of the package and a terminal is a right click away.

Copy a File

Getting files to the remote machine was simple using Visual Studio Code because I could just copy them in the IDE. In AWS Cloud 9 getting files to the machine requires opening a dialog that has a drop box where you can copy files to and they would be uploaded.

A note on permissions

File permissions had to be changed not only for execution of the shell script (chmod +x) but also on the key files so ssh would accept them. This is simple on linux (chmod 600) and very complicated on windows.

Get in touch.

If you have a hint be sure to contact me on  twitter .

If you just want to hang out you may have a chance to catch me on  twitch .

Bibliography, sort of…

missing separator
Git Tips
Cloud 9 Experimental
Cloud 9 Full Stack Part 1
Chmod permission explained
Introduction to AWS Cloud9
Code Cloud IDE Crash Course
No source control providers registered
error permission denied publickey
Github Network Ports
Install Git EC2
Setup EC2
Setup EC2
Terminal will be reused
Create sh on windos, run on linux
Using Visual Studio Code To Develop With Containers
Setup EC2
vs code c development with containers
is-there-a-way-to-refresh-the-task-list-in-vscode
Visual Studio Code inserts spaces when editing a Makefile
gcc on docker
C++ development with Docker containers in Visual Studio Code
Got permission denied while trying to connect…
Get Started
Running Docker on AWS EC2
How to connect Visual Studio Code to remote server – Fixed
marketplace Kelvin.vscode-sshfs
SSH: Permission denied (publickey)
Windows SSH: Permissions for ‘private-key’ are too open
Develop on a Cloud Machine
Developing for the Cloud in the Cloud.
Using EC2 instance as main development platform
AWS Toolkit for Visual Studio Code
Editing files in your Linux Virtual Machine made a lot easier with Remote VSCode
Remote Pair Programming Made Easy with VSCode Live Share
Connect to your remote Linux computer
Remote Editing with VS Code
SSH FS
C/C++ for Visual Studio Code (Preview)
Integrate with External Tools via Tasks
C++ development with Docker containers in Visual Studio Code