Balaji Vajjala's Blog

A DevOps Blog from Trenches

01.01.setup

  • 1.1 Setup Learning Environment
    • Learning Objectives
    • EXERCISE: (Windows Only) Download and Install Putty
    • EXERCISE: Login to your AWS account
    • EXERCISE: Create a New Key Pair
    • EXERCISE: Launch an AWS Utility instance using CloudFormation
    • EXERCISE: Create an S3 bucket to host credentials
    • EXERCISE: Create an S3 bucket to host artifacts
    • EXERCISE: Apply a bucket policy using CloudFormation
    • EXERCISE: Setup your GitHub Account
    • EXERCISE: Upload SSH keys
    • CLASS EXERCISE: Tools, Commands
    • CLASS EXERCISE: About the sample applications

1.1 Setup Learning Environment

Learning Objectives

By the end of this lesson you will be able to:

  • Setup your environments.
  • Launch a CloudFormation stack.
  • Create a Key Pair.
  • Create an S3 bucket.
  • Access GitHub repos.
  • Establish SSH keys.
  • Launch and SSH into an EC2 instance.
  • Review course resources.

EXERCISE: (Windows Only) Download and Install Putty

  1. Follow the instructions for using Putty in Windows http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/putty.html. You will download putty, pscp and puttygen from http://www.chiark.greenend.org.uk/\~sgtatham/putty/download.html

EXERCISE: Login to your AWS account

  1. Verify that you’re able to login to your assigned student account by going to http://aws.amazon.com/console?region=us-east-1 and enter your username and password. Your username is student01, student02 or other similar pattern. Your password will be given to you by the instructor.

EXERCISE: Create a New Key Pair

  1. Go to the list of key pairs by logging into http://aws.amazon.com/console?region=us-east-1 and going to the EC2 tab in the Management console. Then, select the Key Pairs link on the left panel.
  2. Select the Create Key Pair button and enter cd29 in the Key Pair Name field and the Create button (where 29 is your student id). Save the file onto your computer for future use. Click the Close button.

EXERCISE: Launch an AWS Utility instance using CloudFormation

  1. Login to CloudFormation. Click the Create New Stack button. Enter AWSCLI29 (where 29 is your student id) in the Stack Name field and https://s3.amazonaws.com/filescdcourse/templates/base.template* in the Provide a Template URL field. This template is provided courtesy of AWS Training.*
  2. Click Continue.
  3. In the KeyName field, enter the key pair (i.e. cd29) that you created in the previous section. Select the checkbox next to I acknowledge that this template may create IAM resources and click Continue.
  4. Click Continue again, then Close.
  5. Once the status in CloudFormation is CREATE_COMPLETE, select the checkbox next to AWSCLI29. (where 29 is your student id)
  6. Select the Outputs tab in the bottom panel and copy the DNS name for the instance into your clipboard
  7. (*.nix-only environments) Find the cd29.pem file on your computer (where 29 is your student id). If you are are a *nix-based computer, you will need to modify the permissions to 400.
1
$ chmod 400 cd29.pem
  1. From the directory where your cd29.pem (where 29 is your student id) is located, enter the command below to SSH into the utility instance. In the example below, modify PUBLIC_DNS to your the public DNS provided as a value when selecting Outputs tab for the AWSCLI CloudFormation template you created.
1
$ ssh -i cd29.pem ec2-user@PUBLIC_DNS
  1. Enter yes to the security prompt.

EXERCISE: Create an S3 bucket to host credentials

  1. Create a new S3 bucket and call it cd29creds (where 29 is your student id). Use https://console.aws.amazon.com/s3/home and click the Create Bucket button. IMPORTANT: Be sure to choose US Standard in the Region dropdown box.

EXERCISE: Create an S3 bucket to host artifacts

  1. Create a new S3 bucket and call it cd29artifacts (where 29 is your student id). Use https://console.aws.amazon.com/s3/home and click the Create Bucket button. IMPORTANT: Be sure to choose US Standard in the Region dropdown box.

EXERCISE: Apply a bucket policy using CloudFormation

  1. Login to CloudFormation. Click the Create New Stack button. Enter policy29 (where 29 is your student id) in the Stack Name field and *https://stelligentlabs.s3.amazonaws.com/templates/account_bucket_policies.template* in the Provide a Template URL field.
  2. Click Continue.
  3. Enter the name of the bucket you just created (e.g. “cd29artifacts” – where 29 is your student id) and click Continue.
  4. Click Continue again, then Close.
  5. Once the status in CloudFormation is CREATE_COMPLETE, the policy has been applied to your S3 bucket.

EXERCISE: Setup your GitHub Account

  1. Login to your account by going to https://github.com/login
  2. Go to https://github.com/stelligent/continuous_integration_example
  3. Click the Fork button. A message will display “Where do you want to fork this to?”. Click on the button that says Fork to YOURUSERID.
  4. Go to https://github.com/stelligent/devopsinthecloud
  5. Click the Fork button. A message will display “Where do you want to fork this to?”. Click on the button that says Fork to YOURUSERID.
  6. Go to https://github.com/stelligent/sample_app
  7. Click the Fork button. A message will display “Where do you want to fork this to?”. Click on the button that says Fork to YOURUSERID.
  8. Go to https://github.com/stelligent/devcenter-embedded-tomcat
  9. Click the Fork button. A message will display “Where do you want to fork this to?”. Click on the button that says Fork to YOURUSERID.
  10. Go to https://github.com/stelligent/ciexample_jenkins
  11. Click the Fork button. A message will display “Where do you want to fork this to?”. Click on the button that says Fork to YOURUSERID.
  12. Create an SSH keypair by SSH’ing to the AWSCLI instance you created when launching the CloudFormation stack in the section above. In the example below, you will use the email address that’s registered with your GitHub account. You can find yours by going to https://github.com/settings/profile/. Accept the defaults after running this command below. NOTE: Use your student id instead of 29. For example, student03@stelligent.com
1
2
$ ssh-keygen -t rsa -C "student29@stelligent.com"
            
  1. Display the contents of the public key and copy the contents to your clipboard.
1
2
$ cat ~/.ssh/id_rsa.pub
            
  1. After logging into your GitHub account, go to your GitHub SSH Keys settings at https://github.com/settings/ssh/. Click on the Add SSH Key button, give it a name and paste the contents of the public key into the Key text field. Then, click the Add key button. Enter your GitHub password when prompted.
  2. Go back to the AWS CLI instance, go to the root directory and type the following from the command line. Replace student29 with your GitHub userid.
1
2
$ git clone git@github.com:student29/continuous_integration_example.git
            
  1. Go back to the AWS CLI instance, go to the root directory and type the following from the command line. Replace student29 with your GitHub userid.
1
2
$ git clone git@github.com:student29/devopsinthecloud.git
            
  1. Go back to the AWS CLI instance, go to the root directory and type the following from the command line. Replace student29 with your GitHub userid.
1
2
$ git clone git@github.com:student29/sample_app.git
            
  1. Go back to the AWS CLI instance, go to the root directory and type the following from the command line. Replace student29 with your GitHub userid.
1
2
$ git clone git@github.com:student29/devcenter-embedded-tomcat.git
            
  1. Go back to the AWS CLI instance, go to the root directory and type the following from the command line. Replace student29 with your GitHub userid.
1
2
$ git clone git@github.com:student29/ciexample_jenkins.git
            
  1. From the home directory on the AWSCLI, type ls from the command prompt. You should see continuous_integration_example, devopsinthecloud, sample_app, devcenter-embedded-tomcat and ciexample_jenkins as subdirectories.

EXERCISE: Upload SSH keys

  1. Mac: Secure copy the SSH key files to your computer. Your Public DNS will be different. This example assumes you’re installing to your Desktop folder on your Mac.
1
2
3
4
scp -i cd29.pem ec2-user@PUBLIC_DNS:~/.ssh/id_rsa ~/Desktop
scp -i cd29.pem ec2-user@PUBLIC_DNS:~/.ssh/id_rsa.pub ~/Desktop
scp -i cd29.pem ec2-user@PUBLIC_DNS:~/.ssh/known_hosts ~/Desktop
    
  1. Windows: Secure copy the SSH key files to your computer. Your Public DNS will be different. This example assumes that pscp.exe and cd29.ppk are installed at c:\putty. Modify the locations if yours are different.
1
2
3
c:\putty\pscp.exe -i c:\putty\cd00.ppk ec2-user@PUBLIC_DNS:/home/ec2-user/.ssh/id_rsa c:\putty
c:\putty\pscp.exe -i c:\putty\cd00.ppk ec2-user@PUBLIC_DNS:/home/ec2-user/.ssh/id_rsa.pub c:\putty
c:\putty\pscp.exe -i c:\putty\cd00.ppk ec2-user@PUBLIC_DNS:/home/ec2-user/.ssh/known_hosts c:\putty
  1. In https://console.aws.amazon.com/s3/home, go to the bucket you created above (e.g. cd29creds).
  2. Click on the Upload button.
  3. Click Add Files and add the id_rsa, id_rsa.pub and known_hosts files from the commands above to the cd29creds S3 bucket (where 29 is your student id).
  4. Click Start Upload.

CLASS EXERCISE: Tools, Commands

  1. Tools: Tools used in Course.
  2. Command-Line Options: Commonly-used Commands.

CLASS EXERCISE: About the sample applications

  1. Java App – This example application uses Java, Ant/Maven, MySQL, Tomcat on Linux. All of the application code, infrastructure, configuration and data is located at https://github.com/stelligent/continuous_integration_example/.
  2. Ruby App – This example application uses Rails, Rake, HSQL, Passenger on Linux. All of the application code and data is located at https://github.com/stelligent/sample_app/. All of the infrastructure and configuration is located at https://github.com/stelligent/devopsinthecloud/
  3. Maven Example – This example application uses Java, Tomcat and Maven. All of the application code is located at https://github.com/heroku/devcenter-embedded-tomcat/.