Amazon Web Services (AWS) Cloud9 provides a cloud-based Integrated Development Environment (IDE) where you can author, test, and deploy your .NET Core and PowerShell-based applications. You can connect to your Cloud9 IDE using a web browser.
One of my favorite features offered by Cloud9, that enables developers to comfortably use it, is the support for both emacs and vim editor modes. Furthermore, if you switch between physical systems a lot, such as multiple laptops, tablets, and desktop computers, Cloud9 offers a consistent, web-based development environment. You simply connect back into your IDE, and continue where you left off, when you were previously connected to it from a completely different system.
The default Cloud9 environment doesn’t have PowerShell pre-installed, however Cloud9 supports custom SSH-based environments. Thanks to this capability, you can set up a customized / tailored development environment nearly anywhere.
In the remainder of this article, let’s dive deep and explore how you can set up your own Cloud9 environment, with .NET and PowerShell, in your AWS account.
Create Your Cloud9 Environment
To start creating your custom Cloud9 environment with PowerShell and .NET you’ll start by creating a new SSH-based Cloud9 environment. This is achieved through the AWS Management Console, by navigating to the Cloud9 service.
- Open the AWS Management Console and navigate to Cloud9
- Click the Create Environment button
- Give your Cloud9 environment a Name and Description
- Click the Next Step button
- Select the Connect and run in remote server (SSH) option
- For the User field, type ubuntu
At this point, you’ll pause in this browser tab, and switch over to the EC2 service in the AWS Management Console. You’ll need to come back to the Cloud9 console to retrieve the public key, and insert the public IPv4 address of your EC2 instance. Continue onto the next section.
Deploy a Linux EC2 Instance
Next, you’ll create a custom Linux server on Amazon Elastic Compute Cloud (EC2), using the Ubuntu .NET Amazon Machine Image (AMI). This AMI is provided by AWS. Once you’ve created the new Linux server (EC2 instance), you’ll connect your Cloud9 environment to it over an SSH channel.
You might be asking yourself: how does Cloud9 connect securely to my Ubuntu .NET Linux EC2 instance? When you create a new SSH-based Cloud9 environment, you are provided an SSH public key, which you then need to embed into the /home/ubuntu/.ssh/authorized_keys file. You can do this using an Amazon EC2 UserData script, which executes at first-launch time of your new Linux server.
To launch your new EC2 instance, follow the steps below.
- Open a new web browser tab, and navigate to the Amazon EC2 service
- Select the Launch Instance button
- Scroll down and select the .NET Core with Ubuntu Server AMI
- On the next screen, select the Next: Configure Instance Details button
- Expand the Advanced Details section
- Copy / paste the EC2 User Data script below into the User Data field
- Go back to your Cloud9 web browser tab, select the Copy key to clipboard button
- Go back to the EC2 web browser tab, and paste the public key into the User Data field, to replace <CLOUD9PUBLICKEY>
- Select the Review and Launch button, then Launch, then Proceed without a key pair
NOTE: You don’t need to provide a SSH key pair for the EC2 instance itself, unless you want to be able to SSH directly into it. Since you’ll be accessing the EC2 instance using the Cloud9 interface, you won’t necessarily need to SSH into it.
EC2 User Data
In the steps above, use this EC2 User Data to bootstrap your EC2 instance. This simple script will install Python 2.7 and Node.js, and copy the Cloud9 public key into the SSH authorized_keys file, so Cloud9 can remotely install itself onto your EC2 instance.
#!/bin/bash echo "<CLOUD9PUBLICKEY>" >> /home/ubuntu/.ssh/authorized_keys apt update apt-get install python2.7 nodejs --yes
Finish Cloud9 Environment Configuration
Now that you’ve deployed your EC2 instance, wait for it to finish initializing. It should only take a few minutes for it to become ready. You can monitor the EC2 instance in the AWS Management Console, navigate to the Status Checks tab for the instance ID, and then wait for the System Status Checks and Instance Status Checks to return successfully.
Once EC2 instance has become available, follow these steps to finish the Cloud9 environment configuration.
- Copy the public IPv4 address of the EC2 instance
- Switch back to the Cloud9 web browser tab
- Paste the IPv4 address of the EC2 instance into the Host field
- Override the default Node.js binary path to /usr/bin/nodejs instead
- Click the Next Step button, then Create Environment
- In the first-run experience, choose Always Install Everything, and hit the Finish button
After following these steps, wait a few moments for your Ubuntu-based Cloud9 development environment to appear! Below are some screenshots of the final stages of setup, and a sample of editing a PowerShell project in Cloud9.
In this demonstration video, we take a brief look at how to create a custom SSH-based Cloud9 environment, and connect it to an Amazon EC2 instance running in your AWS account, using the Ubuntu .NET AMI.
After reviewing this article and video, you should have a high-level understanding of how to set up a custom AWS Cloud9 development environment, with .NET Core and PowerShell support, in your AWS account. If you have feedback about the Cloud9 customer experience, that you’d like to pass on to the AWS Cloud9 service team, feel free to reach out to your AWS account team directly. Alternatively, you can send me an e-mail at firstname.lastname@example.org, and I will do my best to help you locate your account team contacts, or file the feedback directly for you.
Check out the 15-minute keynote presentation from AWS re:Invent 2017, where the AWS Cloud9 team introduces the IDE, now available as part of the AWS platform. You can also view a live demonstration of AWS Cloud9 at the re:Invent 2017 Launchpad.