Setup Cloud9 Development Environment

AWS Cloud9 is a cloud-based integrated development environment (IDE) that lets you write, run, and debug your code with just a browser. It includes a code editor, debugger, and terminal. Cloud9 comes prepackaged with essential tools for popular programming languages, including JavaScript, Python, PHP, and more, so you don’t need to install files or configure your development machine to start new projects.

The Cloud9 workspace should be built by an IAM user with Administrator privileges, not the root account user. Please ensure you are logged in as an IAM user, not the root account user.

Ad blockers, JavaScript disablers, and tracking blockers should be disabled for the cloud9 domain, otherwise connecting to the workspace might be impacted.

Create a new environment

  1. Go to the Cloud9 web console.
  2. At the top right corner of the console, make sure you’re using this region: Ohio (us-east-2)
  3. Select Create environment
  4. Name it AppSyncWorkshop, and go to the Next step
  5. Select Create a new instance for environment (EC2) and pick m5.large
  6. Leave all of the environment settings as they are, and go to the Next step
  7. Click Create environment

Clean up the layout

When the environment comes up, customize the layout by closing the welcome tab and lower work area, and opening a new terminal tab in the main work area: c9before

Your workspace should now look like this: c9after

This setup uses the TextMate theme for the editor, and Flat Light for the UI.

You can select your preferred theme by selecting them in View / Themes in the Cloud9 workspace menu.

Increase root volume size (optional)

This is an optional but recommended step to avoid running out of space when installing npm modules in later labs.

In the Cloud9 workspace menu, select File / New File. Copy/paste the code below. Name the file resize.sh.

#!/bin/bash

# Specify the desired volume size in GiB as a command-line argument. If not specified, default to 20 GiB.
SIZE=${1:-20}

# Get the ID of the environment host Amazon EC2 instance.
INSTANCEID=$(curl http://169.254.169.254/latest/meta-data//instance-id)

# Get the ID of the Amazon EBS volume associated with the instance.
VOLUMEID=$(aws ec2 describe-instances \
  --instance-id $INSTANCEID \
  --query "Reservations[0].Instances[0].BlockDeviceMappings[0].Ebs.VolumeId" \
  --output text)

# Resize the EBS volume.
aws ec2 modify-volume --volume-id $VOLUMEID --size $SIZE

# Wait for the resize to finish.
while [ \
  "$(aws ec2 describe-volumes-modifications \
    --volume-id $VOLUMEID \
    --filters Name=modification-state,Values="optimizing","completed" \
    --query "length(VolumesModifications)"\
    --output text)" != "1" ]; do
sleep 1
done

if [ $(readlink -f /dev/xvda) = "/dev/xvda" ]
then
  # Rewrite the partition table so that the partition takes up all the space that it can.
  sudo growpart /dev/xvda 1

  # Expand the size of the file system.
  sudo resize2fs /dev/xvda1

else
  # Rewrite the partition table so that the partition takes up all the space that it can.
  sudo growpart /dev/nvme0n1 1

  # Expand the size of the file system.
  sudo xfs_growfs -d /
fi

Save the file and then in your terminal, execute the command:

sh ./resize.sh