AWS

Steps to create an AWS Cloud9 EC2 development environment

Lab Details

  1. This lab walks you through the steps to create an AWS Cloud9 EC2 development environment and run python code in the environment.
  2. You will practice using AWS Cloud9.
  3. Duration: 30 minutes
  4. AWS Region: US East (N. Virginia).

Introduction

AWS Cloud9

  1. AWS Cloud9 is an integrated development environment or IDE.
  2. The AWS Cloud9 IDE offers a rich code-editing experience with support for several programming languages and runtime debuggers. It also has a built-in terminal with a preconfigured CLI.
  3. It contains a collection of tools that you use to code, build, run, test, and debug software.

How does AWS Cloud9 Work?

  1. We use the AWS Cloud9 IDE, running in a web browser on your local computer, to interact with your AWS Cloud9 environment.
  2. A computing resource like an EC2 Instance or our own server connects to that environment.
  3. Our work is stored in an AWS CodeCommit repository or another type of remote repository.

Lab Tasks

  1. Log into the AWS Management Console.
  2. Create an AWS Cloud9 development environment.
  3. Go through the Cloud9 IDE.
  4. Install Python using the terminal.
  5. Create a python file and add the code.
  6. Run the python file.

Architecture Diagram

Task 1: Launching Lab Environment

  1. Launch the lab environment by clicking on . Please wait until the lab environment is provisioned. It will take less than 2 minutes to provision the lab environment.
  2. Once the Lab is started, you will be provided with IAM user namePasswordAccessKey and Secret Access Key.
  3. Click on the , AWS Management Console will open in a new tab.
  4. In the AWS sign in page, the Account ID will be present by default.
    • Leave the Account ID as default. Do not remove or change the Account ID otherwise you cannot proceed with the lab.
  5. Copy and paste the IAM user name and Password into AWS Console. Click on Sign in to log into the AWS Console.

Note : If you face any issues, please go through FAQs and Troubleshooting for Labs.

Steps

Create an AWS Cloud9 Development Environment

  1. Navigate to  and search for Cloud9 and select it.
  2. Choose the Create Environment button. If you do not have any AWS Cloud9 environments yet, the button is shown on a welcome page.
  1. On the Name environment page, for Name, enter a name for your environment.
    • Name: whiz_env
  2. To add a description to your environment, enter it in Description.
    • Description: Creating a new Cloud9 Environment
  3. Choose the Next step.
  1. On the Configure settings page, for Environment type, choose to Create a new EC2 instance for the environment (direct access) which Launches an Amazon EC2 instance that AWS Cloud9 can connect to directly over SSH.
  2. For Instance type, choose t2.micro (1 GiB RAM + 1 vCPU)
  1. Under the Platform, choose the type of Amazon EC2 Instance as Amazon Linux. AWS Cloud9 creates the instance and connects it to the environment.
  2. Under the Cost-saving setting, leave it as default.
  1. Leave the Network settings (advanced) as default. Click on Next Step.
  1. On the Review page, choose to Create environment. Wait while AWS Cloud9 creates your environment. This can take several minutes.
  2. Once AWS Cloud9 creates your environment, it displays the AWS Cloud9 IDE for the environment.
  3. If AWS Cloud9 doesn’t display the IDE after at least five minutes, there might be a problem with your web browser or instance or others.

Go through the Cloud9 IDE

  1. Go through the Cloud9 IDE.
  1. To go to the cloud9 dashboard, click on Go to Your Dashboard.
  1. You can click on Open IDE anytime to go to the environment.

Install Python Using the Terminal

  1. In a terminal session in the AWS Cloud9 IDE, confirm whether Python is already installed by running the python –version command. 
  1. To start a new terminal session, on the menu bar choose WindowNew Terminal.
  2. Run the yum update command to help ensure the latest security updates and bug fixes are installed.
  • sudo yum -y update
  1. If python is not present, Install Python by running the install command.
  • sudo yum -y install python36

Create a Python File and Add Code

  1. In the AWS Cloud9 IDE, create a file with the following content and save the file with the name hello.py. To create a file, on the menu bar choose FileNew File. To save the file, choose FileSave.
  • print(“Hello World!”)
  • print(“The sum of 2 and 3 is 5.”)
  1. The screenshots are mentioned below.

Run the Python File

  1. In the AWS Cloud9 IDE, on the menu bar choose RunRun ConfigurationsNew Run Configuration.
  1. On the [New]-Stopped tab, enter hello.py in the command and choose Run.
  1. You can check the Output and compare it with your code.

Completion and Conclusion

  1. You have successfully created an AWS Cloud9 Development Environment
  2. You have successfully gone through the Cloud9 IDE.
  3. You have successfully installed python using the terminal.
  4. You have successfully created a python file and added the code.
  5. You have Run the python file.

Validation Test

  1. Once the lab steps are completed, please click on the  button on the right-side panel.
  2. This will validate the resources in the AWS account and shows you whether you have completed this lab successfully or not.
  3. Sample output :

Resource Cleanup

  1. Let us delete the created resources.
  2. In the list of environments, for the environment, you want to delete, Choose the title of the card for the environment. Then choose Delete.
  1. In the Delete dialog box, type Delete, and then choose Delete.
  1. AWS Cloud9 also terminates the Amazon EC2 instance that was created and connected to that environment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: