Thursday, November 5, 2015

AWS: Amazon Web Services


EC2 stands for "Elastic Compute Cloud". This allows running a remote virtual machine instance in the AWS cloud. The remote machine can choose to have OS windows or Linux(redhat, suse, ubuntu or amazon's linux). The remote machine instance can be-
1. General Purpose
2. Compute optimized
3. GPU instance
4. Memory optimized
5. Storage optimized

AWS basics:

For launching an existing EC2 instance, 
1. Click on EC2
2. Click the instances link @left panel.
        -> This shows the list of instances
3. Select the instance and click on the "Actions" drop down at the top
4. To start/stop the instance, select the "instance state" and change the state.

After launching a remote instance, you will get a public IP address.


Connect to EC2 from Linux:

 Run the following command to login to the remote machine instance-

ssh -i "ec2-keypair.pem" ubuntu@
            Where ec2-keypair.pem is the private key file


Troubleshooting:

1. Error:
 ssh: connect to host port 22: Connection timed out

    a. Click the "security group" link @left panel.
        -> This shows the list of security groups
    b. Right click on your security group and select "Edit inbound rules"
    c. Make sure that your public IP is added as "custom IP" and give IP address as xx.xx.xx.xx/32

Connect to EC2 from Windows:

Setting up EC2 with nodejs:

Follow this link for setting up the EC2 instance for node.js-
http://therightchoyce.tumblr.com/post/37209565860/installing-nodejs-on-an-ec2-ubuntu-instance-for

Test out the node.js with the following hello world program:


         var http = require('http');



         var server = http.createServer(function (request, response) {
                response.writeHead(200, {"Content-Type":"text/plain"});
                response.end("Hello world");
         });
        
         server.listen(8000);
        console.log("Server running on 8000");


Save the file to example.js and run with 
nodejs example.js

On the browser, you should see "Hello world" printed on :8000

Creating a project repository in Github


1. Create an account in github and verify your email
2. Click on the dropdown on top right side with a + sign. It takes you to the url https://github.com/new
3. Give a repository name and click on create repository.


Working with github:
In order to clone the repository, you need-
1. Create an ssh key by following this link
https://help.github.com/articles/generating-ssh-keys/

2. Add the ssh public key to the github page at this location
https://github.com/settings/ssh

3. Run the following command-
 git clone git@github.com:/.git

4. Do the following to set your username/password

git config --global user.name "your name"
git config --global user.email "your@email.com"

5. Pushing your change to github:
git push origin  localbranch:master