Cloud9
Although we said everything is going to be code, and while it is possible to create our integrated development environment (IDE) as code, we are going to use the AWS console for this exercise. Log in to the console, click the Services button, and search or scroll to the Cloud9 service. This cloud native IDE is provided for us by Amazon, so we will use it in order to simplify our security and easily integrate with other AWS services. Go ahead and create an environment (press the big orange Create environment button):
Select the smallest available option (when we were writing this book, it was the t2.micro (1 GiB RAM + 1 vCPU) instance type) for now and keep all of the other defaults. Press the button at the bottom of the page for the Next step:
Check the settings on the Review step page and confirm; you should then eventually see something like the following screenshot. Creating environments takes a few minutes:
Right-click on the cloudpatterns folder and create a new folder called ch2:
Now we will install Terraform to help us to manage our infrastructure as code configuration. Click Create File and add the following code:
#! /bin/bash
mkdir download
cd download/
wget https://releases.hashicorp.com/terraform/0.11.11/terraform_0.11.11_linux_amd64.zip
unzip terraform_0.11.11_linux_amd64.zip
mv terraform /usr/bin/terraform
terraform
exit
Save the file in your ch2 folder as terraform_install.sh, then click Run:
You will see some scrolling at the bottom of your window, then Terraform help will appear. You can close the Run window and click in the bash window:
Now that we have some source code, we need a place to keep it outside of Cloud9. We will create an AWS CodeCommit source repository using Terraform. Let's start with a new codecommit.tf file:
provider "aws" {
region = "us-east-1"
}
resource "aws_codecommit_repository" "cloudpatterns" {
repository_name = "cloudpatternsrepo"
description = "This is a demonstration repository for the AWS Cloud Patterns book."
}
We need to initialize the Terraform environment using terraform init first. This will configure the AWS provider for you. Then, you can run terraform apply:
Great! Let's put our code into our repository.
Here is some example code for creating a Cloud9 environment with Terraform, create_env.tf:
resource "aws_cloud9_environment_ec2" "cloudpatterns" {
instance_type = "t2.micro"
name = "example-env"
automatic_stop_time_minutes = "30"
description = "My Cloud Patterns Environment"
}