Menu
AWS Cloud9
User Guide

Working with Amazon Lightsail Instances in the AWS Cloud9 Integrated Development Environment (IDE)

You can use the AWS Cloud9 IDE to work with code on Amazon Lightsail instances preconfigured with popular apps and frameworks such as WordPress, LAMP (Linux, Apache, MySQL, and PHP), Node.js, Nginx, Drupal, and Joomla, as well as Linux distributions such as Amazon Linux, Ubuntu, Debian, FreeBSD, and openSUSE.

Lightsail is the easiest way to get started with AWS for developers, small businesses, students, and other users who need a simple virtual private server (VPS) solution. Lightsail provides developers compute, storage, and networking capacity and capabilities to deploy and manage websites and web applications in the cloud. Lightsail includes everything you need to launch your project quickly—a virtual machine, SSD-based storage, data transfer, DNS management, and a static IP—for a low, predictable monthly price. For more information, see Amazon Lightsail Features.

In this topic, you create and set up a Linux-based Lightsail instance that is compatible with AWS Cloud9. You then create and connect an AWS Cloud9 SSH development environment to the Lightsail instance.

Note

Completing these procedures might result in charges to your AWS account. These include possible charges for services such as Lightsail. For more information, see Amazon Lightsail Pricing.

To create and set up a more advanced solution that includes a toolchain with the AWS Cloud9 IDE, source control, build, deployment, virtual servers or serverless resources, and more, skip the rest of this topic, and see Working with AWS CodeStar Projects instead.

To use the AWS Cloud9 IDE to work with an Amazon EC2 instance running Amazon Linux that contains no sample code, skip the rest of this topic, and see the IDE Tutorial instead.

Step 1: Create a Linux-Based Lightsail Instance

In this step, you use the Lightsail console to create an Amazon EC2 instance running an app in a Linux-based distribution. This instance automatically includes:

  • A public and private IP address. (You can create a static public IP later.)

  • Access to the instance using SSH over port 22, HTTP over port 80, and HTTPS over port 443. (You can change this.)

  • A block storage disk. (You can attach additional disks later.)

  • Built-in system reporting.

The Lightsail console enables you to back up, reboot, stop, or delete the instance later.

  1. Open and then sign in to the Lightsail console, at https://lightsail.aws.amazon.com.

    We recommend you sign in using credentials for an IAM administrator user in your AWS account. If you cannot sign in as an IAM administrator user, check with your AWS account administrator.

  2. If prompted, choose the language to use in the console, and then choose Save.

  3. If prompted, choose Let's get started.

  4. On the home page, with the Instances tab already selected, choose Create instance.

    
                  Choosing the Create instance button in the Lightsail console
  5. For Instance location, be sure the location matches an AWS Region where you want to create the instance and where AWS Cloud9 is available. For more information, see AWS Cloud9 in the Amazon Web Services General Reference. To change the AWS Region, Availability Zone, or both, choose Change AWS Region and Availability Zone, and then follow the onscreen instructions.

  6. For Pick your instance image, with Linux/Unix already chosen for Select a platform, and Apps + OS already chosen for Select a blueprint, choose a blueprint.

    
                  Choosing an instance platform and blueprint in the Lightsail console

    Note

    If you want to create an instance with no app, choose OS Only instead of Apps + OS, and then choose a distribution.

    To learn about the available choices, see Choosing an Amazon Lightsail instance image on the Lightsail website.

  7. For Choose your instance plan, choose a plan, or leave the selected default plan.

  8. For Name your instance, type a name for the instance, or leave the suggested default name.

  9. For the number of instances, type the number of instances you want to create, or leave the default of a single instance (x 1).

  10. Choose Create.

Step 2: Set up the Instance to Use It with AWS Cloud9

In this step, you connect to the running instance and then set it up so that AWS Cloud9 can use it later.

Note

The following instructions assume you chose Apps + OS in the previous step. If you chose OS Only and a distribution other than Ubuntu instead, you might need to adapt the following instructions accordingly.

  1. With the Lightsail console still open from the previous step, on the Instances tab, in the card for the instance, choose the instance's name.

    
                  Choosing to show instance details in the Lightsail console
  2. On the Connect tab, for Connect using your own SSH client, note the Public IP and User name values, as you will need them later.

    
                  Instance public address and user name showing in the Lightsail console
  3. Choose Connect using SSH.

  4. Be sure that the instance has the latest system updates. To do this, in the terminal session that appears, run the command sudo apt-get update .

  5. Check to see if Python is installed, and if it is, check to be sure the version is 2.7. To check the version, run the command python --version , and note the version number that appears. If no version number appears, or if the version is not 2.7, install Python 2.7 on the instance by running the command sudo apt-get install python .

  6. Check to see if Node.js is installed, and if it is, check that the version is 0.6.16 or later. To check the version, run the command node --version , and note the version number that appears. If no version number appears, or the version is not 0.6.16 or later, we recommend you use Node Version Manager (nvm) to install Node.js on the instance.

    To do this, run the following commands one at a time, in the following order, to update the instance, install Node Version Manager (nvm) on the instance, activate nvm on the instance, and then install the latest version of Node.js on the instance.

    sudo apt-get update curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash . ~/.bashrc nvm install node
  7. Run the command which node , and note the value that appears. You will need it later.

    Note

    If the output of the command which node is something like /usr/sbin/node, AWS Cloud9 won't be able to find Node.js in that path. Instead, use nvm to install Node.js, as described in the previous step in this procedure. Then run the command which node again and note the new value that appears.

Step 3: Create and Connect to an AWS Cloud9 SSH Development Environment

In this step, you use the AWS Cloud9 console and the instance's terminal to create an SSH environment and then connect the environment to the running instance.

  1. With the terminal session still open from the previous step, sign in to the AWS Cloud9 console, at https://console.aws.amazon.com/cloud9/.

    Note

    For this step, you will work with two different AWS services at the same time. If you signed in to the Lightsail console as an IAM administrator user, but you want a different entity to own the new SSH environment, we suggest opening a different web browser and signing in to the AWS Cloud9 console as that entity.

  2. In the AWS Cloud9 console, choose the AWS Region that matches the one you created the instance in.

    
                  AWS Region selector in the AWS Cloud9 console
  3. If a welcome page is displayed, for New AWS Cloud9 environment, choose Create environment. Otherwise, choose Create environment.

    
                  Choosing the Next step button if welcome page is displayed

    Or:

    
                  Choosing the Create environment button if welcome page is not displayed
  4. On the Name environment page, for Name, type a name for your environment.

  5. To add a description to your environment, type it in Description.

  6. Choose Next step.

  7. On the Configure settings page, for Environment type, choose Connect and run in remote server (SSH).

  8. For User, type the User name value you noted earlier.

  9. For Host, type the Public IP value you noted earlier.

  10. For Port, leave the default value of 22.

  11. Expand Advanced settings.

  12. For Environment path, type the path that AWS Cloud9 will start from after login, which is ~/ (the root of the user's home directory).

  13. For Node.js binary path, type the value of the command which node you noted earlier.

  14. Leave SSH jump host blank.

  15. Store the public SSH key that AWS Cloud9 creates for this environment in your system clipboard. To do this, choose Copy key to clipboard.

    Note

    To see the public SSH key value that was copied, expand View public SSH key.

  16. Save the public SSH key value you just copied to the instance. To do this, use vi, a popular text editor, which is already installed on the instance:

    1. In the terminal session for the instance, run the command vi ~/.ssh/authorized_keys .

    2. In the vi editor that appears, go to the end of the file, and switch to insert mode. To do this, press G, then A. (-- INSERT -- appears at the bottom of the vi editor.)

    3. Add two carriage returns to the end of the file by pressing Enter twice.

    4. Paste the contents of your system clipboard, which contains the public SSH key value you just copied, to the terminal session clipboard. To do this, in the bottom corner of the terminal session window, choose the clipboard button, then paste the contents of your system clipboard into the box.

      
                        Opening the Lightsail terminal session clipboard
    5. Paste the contents of the terminal session clipboard into the vi editor. To do this, at the insertion point in the vi editor, press Ctrl + Shift + V.

    6. Save the file. To do this, press Esc to enter command mode. (-- INSERT -- disappears from the bottom of the vi editor.) Type :wq (to write the file and then quit the vi editor), and then press Enter.

  17. Back in the AWS Cloud9 console, choose Next step.

  18. On the Review choices page, choose Create environment. Wait while AWS Cloud9 creates your environment and then displays the AWS Cloud9 IDE for the environment. This can take several minutes.

After AWS Cloud9 creates your environment, it displays the AWS Cloud9 IDE for the environment.

If AWS Cloud9 doesn't display the IDE after at least five minutes, there might be a problem with your web browser, your AWS access permissions, the instance, or the associated virtual private cloud (VPC). For possible fixes, see Cannot Open an Environment in Troubleshooting.

Step 4: Use the AWS Cloud9 IDE to Change the Code on the Instance

Now that the IDE appears for the new environment, you can use the terminal session in the IDE instead of the Lightsail terminal session. The IDE provides a rich code editing experience with support for several programming languages and runtime debuggers, as well as color themes, shortcut keybindings, programming language-specific syntax coloring and code formatting, and more.

To learn how to use the IDE, see Tour the IDE in the IDE Tutorial.

To learn how to change the code on your instance, we recommend the following resources.