Saturday, September 23, 2017

Amazon EC2 Instance create and connect with Putty

What is AWS EC2

Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services(AWS) cloud. Using Amazon EC2 eliminates your need to invest in hardware up front, so you can develop and deploy applications faster.
Amazon EC2 allows us to get compute power in cloud through the launching of virtual servers called instances. When you launch an instance, you can make use of the compute as you wish, just as you would with an on-premises server. Because you are paying for the computing power of the instance, you are charged per hour while the instance is running. When you stop the instance, you are no longer charged.
There are two main things when launching instances on AWS :
  • the amount of virtual hardware dedicated to the instance and
  • the software loaded on the instance.
These two dimensions of new instances are controlled, respectively, by the Instance Type and the AMI - Amazon Machine Image.

Prerequisites

Before starting up this exercise we need below setup as prerequisites.
  • AWS account – Must have to open one AWS account to do this exercise.
  • SSL Client – PuTTY – This should be installed in Local M/C including PuTTYgenPUTTYPageant applications. Full set of applications related to PutTTY can be downloaded from this link. Just unzip to a convenient location.
So, let’s get started by creating an AWS EC2 instance.

Steps to Create EC2 Instance

  1. Login to AWS console and open EC2 home screen – Once log in and click Services menu in the top left corner of the home screen, we will need to click the EC2 Link under compute section. The EC2 landing page will look like :
    Figure 1.0 : Services Menu with Ec2 Link
    This is how EC2 Home page looks like. This is the place we land when we click EC2 link in the previous step (Figure 1.0).
    Figure 1.1 : EC2 Home Screen
  2. Launch a new virtual server Now we need to click the Launch Instance button from the EC2 Home page.This will start the instance creation wizard which will guide us through the following steps mainly:
    • Selecting an OS
    • Choosing the size of your virtual server
    • Choosing the Extra attached storage we need for this instance
    • Configuring details
    • Reviewing your input and selecting a key pair for SSH
  3. Select AMI – AMI stands for Amazon Machine Images, which is kind of a blue print of the instance that we will create, it tells about the Operating System of the Instance as well as the basic softwares that will be pre-installed. So in this step, while choosing AMI, we are choosing the underlying Operating System(OS) and the preinstalled software bundles that would be available in the instance upfront.We need to choose AMI based on our need. We will choose only those AMIs which falls under Free Tire Eligible type. An AMI is the basis your virtual server starts from. AMIs are offered by AWS, by thirdparty providers, and by the community. We can also create custom AMI based on our need. Some AMIs are chargeable. Here for this exercise we will choose Ubuntu Server 16.04 LTS(HVM) AMI.
    Figure 3.0 : Select AMI
    Click on the Select button beside the AMI to proceed with the sect step.
  4. Select Instance Type – It’s now time to choose the computing power needed for your virtual server. Instance Type indicates the computing power of the instance by allocating the amount of virtual hardware dedicated to the instance. On AWS, computing power is classified into instance types. An instance type primarily describes the number of vCPUs and the amount of memory an instance will be allocated to once created. We will choose only the Free Tire Eligible Instance Type (t2.micro) which provides 1 vCPU and 1 GB of Memory. AWS has already defined many instance types, we will now choose the t2.micro instance type for this exercise. Once instance type is selected, click on button Next: Configure Instance Details in the bottom right corner of the page to proceed with the next steps.
    Figure 4.0 : Instance Type Selection
  5. Instance Details page This will look like below. Here we will take all the default values and proceed with clicking Next: Add Storage button at the bottom right corner of the page. Before proceeding to the next section please note few important things that we can modify here:
    • Number of Instances we are going to create in this wizard.
    • We can select the Spot Instance option, Spot Instances are idle compute capacity that AWS makes available based on bid prices from customers.
    • Networking/Subnet/Public IP setting – This is the VPC under which the instance would be created, We can choose existing VPC, or create a new VPC here. VPC is itself a large topic which is out of scope of this article. Please follow official AWS documentation for the same.
    • Also we can configure, Shutdown Behavior, Termination Protection Flag(To avoid accidental Termination), Tenancy(Common vs dedicated H/W), Cloud Watch Detailed Monitoring. Here some of them are chargeable option.
    • We can Change those later also once the Instance has been created.
    Now we will proceed to add EBS (Elastic Block Store) volume details associated with this instance. Configure Instance Details screen will look like
    Figure 5.0 : Configure Instance Details
  6. Add EBS Storage – EBS stands for Elastic block storage. It is basically network-attached storage attached your virtual server. This page will help us to configure Storage that will be associated with the EC2 instance that we are going to launch. We will choose default values to avoid extra cost. Make sure you choose the capacity which falls under Free Tire Eligibility to avoid incurring extra cost.
    Review and click Next: Add Tags button at the bottom right corner of the page to proceed. The EBS volume configuration page will look like
    Figure 6.0 : EBS volume configuration
  7. Add Tags – Tags are kind of an identifier of any AWS resources, with Tags we can easily locate the resource in future and also it helps us to classify the resources. Tags help you to organize resources on AWS. We can add max 50 tags to a particular resources. It is a simple Key value pair associated with the resource.
    In this step we will add one tag Name with value myfirstec2server. Once tag is created, we will proceed with configuring security group by clicking the “Next: Configure Security Group” button at the bottom right corner of the page. Add Tag screen will look like:
    Figure 7.0 : EC2 Add Tag
  8. Configure Security Group – This section is to define a firewall that helps to secure our virtual server. A security group is a virtual stateful firewall that controls inbound and outbound network traffic to AWS resources and Amazon EC2 instances. All Amazon EC2 instances must be launched into a security group. If a security group is not specified at launch, then the instance will be launched into the default security group for the Amazon VPC. The default security group allows communication between all resources within the security group, allows all outbound traffic, and denies all other traffic.In this screen we can create/reuse security groups based on our need.
    In this example, assuming that we don’t have any security group created, We will choose the default option and will proceed. To proceed with next page, we will click on the Review and Launch button at the bottom right corner of the page. The Security Group configuration screen will look like:
    Figure 8.0 : Security Group Configuration Screen
  9. Review and associate Key pair – We will now review all the configurations that we have selected so far in this screen and to proceed further we will click on Launch button at the bottom right corner of the page.
    Figure 9.0 : Review Launch configurations
    Once we proceed, we will have to select the Key pair which will be used for authentication while connecting with the instance.
  10. Create a new Key Pair -Logging in to your virtual server requires a key. We use a key instead of a password to authenticate. We will create a new Key pair by choosing appropriate option from drop down and will have to provide a name of the key-pair file and then we need to download that file by clicking the Download Key Pairbutton in the page. A key is much more secure than a password, and using keys for SSH is mandatory for virtual servers running Linux on AWS. In our case we have chosen Ubuntu Linux, so creating a Key-pair is a must for us here. In this step if we create a new Key-pair, we get one file of type .pem extension. Here are the steps of creating the Key pairs. Instructions are self describing and very easy to follow.
    Figure 10.0 : Key Pair Creation Step 1
    Figure 10.1 : Key Pair Creation Step 2
    Figure 10.2 : Key Pair Creation Step 3
    Once we have created and downloaded the Key pair we need to proceed by clicking Launch Instances button in the Figure 10.2 page.
  11. Finish Creation Process – Once we have clicked Launch Instances button in the last page where we have created Key pairs, we will start the actual instance creation step as below.
    Figure 11.0 : Instance Creating Last step
    Finally this is the screen where we will see the details of the instance that we have just created.
    Figure 11.1 : Instance Created
Now we have created our first EC2 Instance. Next we will connect to this instance from our local workstation and will install one software (Linkchecker) in EC2 instance and will learn to use that software.

Connect to EC2 Instance

AWS has provided a very good documentation in this regard. Here are the basic steps for configuring and connecting to the instance through putty.
  • AWS provided steps – In the instance details page, we can click Connect button to view the pop up like this. This will give us the required steps and information regarding connecting to the instance, Also we can go to the actual AWS documentation by going to the link in the pop up – connect using PuTTY link.
    Connect Pop up Details
    Official AWS steps for PuTTY in Windows
  • Use PuTTYgen to convert the Key File – Now we need the .pem file we downloaded while creating EC2 instance. Now we will open PuTTYgen app to convert this .pem file to .pkk file which will be used by PuTTY to login to the instance terminal.
    In the PuTTYgen application follow the below step to convert the .pem file.
    1. Run the application PuTTYgen.
    2. Select RSA radio button under Type of Key to Generate.
    3. Click Load.
    4. Because PuTTYgen displays only *.pkk files, you need to switch the file extension of the File Name field to All Files.
    5. Select the .pem file [in my case it is sajal_ec2_key_pair.pem], and click Open.
    6. Confirm the dialog box.
    7. Click Save Private Key. Ignore the warning about saving the key without a passphrase.
    Here are few screen shots for those steps.
    PuTTYgen Steps
    PuTTYgen Steps
    PuTTYgen Steps
    PuTTYgen Steps
    PuTTYgen Steps
  • Start Pageant.EXE and select the .pkk file. Once Pageant stated we will need to add the Key by selecting the .pkk file we have already created. Here are the sample steps for this.
    PAGENT step 1
    PAGENT step 1
  • Login to EC2 Instance – Once we have Pageant.exe running and added the key .pkk file, Open Putty.exe and give public IP address of the Instance for connect. We can get the public ip fro the instance details screen in the AWS EC2 page. Now we need to give user name as ubuntu in the login as prompt. If everything goes well this would be authenticated and log in to the instance.
    Public IP address for AWS console
    Putty With Public IP
    Putty Login
So now we are able to SSH connect to EC2 instance through putty.

Installing softwares on EC2 Instance

Now we will install linkchecker software and will use that to do some testing.
  • open putty and login ti the terminal as described above and enter the command sudo apt-get install linkchecker -y in the terminal. This will install the linkchecker software in the instance.
  • Now test the linkchecker by simply providing some URL like linkchecker https://...
  • Here is the sample screen related to link checker install and usage.
    Check 12factor website
    Install Software

Checking Logs on EC2 Instance

We can view the console log of EC2 instance from the AWS console itself by clicking on the Actions menu, choose Instance Settings > Get System Log. Here is the sample screen looks like:
EC2 view System Logs

How to Terminate EC2 Instance

We can terminate EC2 instance by clicking the menu option Actions > Instance State > Terminate.
Here are the consequent steps related to termination of the instance. Please note that termination means Deletion/removal of the instance from AWS system. Also we can stop the instance. Please choose accordingly.
EC2 Instance Termination
EC2 Instance Termination
EC2 Instance Termination


EC2 Instance Termination

Tuesday, September 19, 2017

GitHub Data Push using local Git

Go to the download link and click on the version as per your system. Let it download and then install it.
This will install git in your system, along with command prompt for it called git bash. The next step is to configure the system with your git account. Once you have signed up for GitHub, you can use this to setup your system. Open up you git bash and type the following commands.  
git config --global user.name "jalFaizy"
git config --global user.email ff@ff.com
Now there’s two tasks you have to do.
  • Create a repository on GitHub
  • Connect it with your code directory.
To accomplish the tasks, follow on to the steps mentioned below
Step 1: Add a new repository on GitHub
Step 2: Give proper descriptions to setup the repository.
Step 3: Get link to the repository
Step 4: Connect you local repository with the repository on GitHub with the commands below.
git init
git remote add origin <add link here>
git pull origin master
Now if you want GitHub to ignore the changes in the files you can mention them in .gitignore file. Open it and add the file or folder you want to ignore.
git add -A .
git commit -m "add first commit"
git push -u origin master
Now each time you want to save your progress, run these commands again
git add -A .
git commit -m "<add your message>"
git push -u origin master
This will ensure that you can go back to where you left off!

Thursday, August 31, 2017

Mongo DB Environment Set Up

  1. Download MongoDB this link link.
  2. Review MongoDB folder.

    In MongoDB, it contains only executable files 10 Plus(exe) in the bin folder. This is true, and That are the required files to MongoDB, it's really hard to believe for a developer like me Who eats from a relation database background.
    path:- Files under $MongoDB/bin folder
  3. Configuration File

    Create a MongoDB config file, it’s just a text file, for example C:\mongodb\mongo.config:
    #store data here
    dbpath=C:\mongodb\data
    
    \\all output go here
    logpath=C:\mongodb\log\mongo.log
    
    \\log read and write operations
    diaglog=3
  4. Run MongoDB server

    Use mongod.exe --config C:\mongodb\mongo.config to start MongoDB server.
    C:\mongodb\bin>mongod --config C:\mongodb\mongo.config
    All output going to: C:\mongodb\log\mongo.log
  5. Connect to MongoDB

    Uses mongo.exe to connect to the started MongoDB server.
    C:\mongodb\bin>mongo MongoDB shell version: 2.2.3 connecting to: test
    //mongodb shell
  6. MongoDB as Windows Service

    Add MongoDB as Windows Service, so that MongoDB will start automatically following each system restart. Install as Windows Service with --install.
    C:\mongodb\bin> mongod --config C:\mongodb\mongo.config --install
    A Windows service named “MongoDB” is created.
    To start MongoDB Service:
    net start MongoDB
    To stop MongoDB Service
    net stop MongoDB
    To remove MongoDB Service
    C:\mongodb\bin>mongod --remove

Wednesday, August 30, 2017

Steps to Becoming a Successful Programmer

Steps to Becoming a Successful Programmer

1. Willingness to Learn New Technologies

What we have learned and implemented can quickly become obsolete as technology is always changing. So, as a programmer, you just have to update your skills accordingly and stay up to date. When a new technology comes on the market, it's typically made up of a few process and syntax changes, but the logic is the same so you can grasp it very fast.

2. Debugging Skills

Programmers create code, but when the software does not work as expected, the programmer should be able to root out the problem quickly and effectively.
So, instead of making changes to all your code, make a proper flow document while creating your program so that you can investigate your code very quickly and find the issue as soon as possible. By making a proper document, you can debug your program quickly without wasting much time.

3. Problem-Solving Skills

When an average programmer gets a project/module, they just start coding. But successful programmers try to find the root of the problem that their code is addressing and inform their team leader or project leader. Because sometimes after a project requirement is documented and the project is started, or even after it's completed, we get some issue in the project. So find the issue before it arises.
Also, find a way to solve the issue very quickly.

4. Passion for the Work

Your job time may be nine to five but when you have a passion for doing the job, don’t just walk away when the workday is over. Work until your work is done. I don’t mean to say that if you are not getting the solution then you should sit around frustrated the whole day, but if you're getting close, then just complete it.
Your manager or the higher-ups will appreciate your work, and when you find a good environment your passion will increase.
Also, don’t just sit around when there is no work. Try to build some new application like a game, puzzle, chatting app, etc., which will help to make you more passionate about your work.

5. Grace Under Fire

Programming can be a stressful profession due to tight deadlines. And then there are those times we can’t seem to get anything working. A poor programmer just freezes up and stops working. But a great programmer handles the stressful situation calmly and just keeps on working.

6. Laziness... I Mean Efficiency! 

When there are a lot of tasks and time is running out to complete your project, then only the lazy programmer will find the better and quickest solution for completing the project because he knows very well how to work less and do more.
If you want to find the best way to do something then just ask the lazy person; chances are the lazy person will find the best, quickest, and most efficient way to do it because the lazy person always tries to find a more efficient way.

7. Ability to Handle Failure

As a programmer, you will rarely have success on the first try, so failure is almost a certainty. So take this as a challenge rather than as a sign of defeat. Having patience and persistence is very important to having success in programming. 

8. Willingness to Research

A programming language is just part of the picture. A good and successful programmer always tries to make code which works for their employers and helps to solve business problems. And, sometimes, this requires you to do a little digging. 

9. Teamwork Mentality

As you are a developer, you always work with a team because with the help of team members like the designers, business staff, analysts, and sales staff you can achieve your desired results very effectively.
You will never meet your goals until you work with the team.

10. A Business Perspective

It is easy to work as a programmer in an IT company, but the ideal programmer always focuses on business goals. This allows you to move beyond just working on application ideas that get handed down from on high. Only a business focused programmer can suggest ideas for a new project that may improve efficiency and operations.
Let me know in the comments which point motivates you to become a successful programmer and if you enjoyed this article share it on social media so that every programmer can get the tips for becoming a success in their career.

Monday, August 7, 2017

AWS components

AWS Training Course Objectives

  • Compute (EC2)
  • Storage (S3, EBS, EFS, Storage Gateway & Snowball)
  • Database (RDS, DMS, Redshift)
  • Network and Content Delivery (Route53 VPC &CloudFront)
  • Management Tools (CloudWatch Cloud Formation Trusted Advisor)
  • Security & Identity Compliance (IAM)
  • Application Services (SWF, Elastic Transcoder, Cloud Formation)
  • Messaging (SNS, SQL & SES)
  • Developer tools (Code Pipeline, Code Commit, Code Build and Code Deploy) 

AWS Training Course Prerequisites

  • Absolute Beginners. No prior AWS experience is necessary.
  • Previous System Administration/ Development knowledge would be added advantage.
  • System Administrators Interested in Deploying Applications on AWS
  • Cloud Computing Enthusiasts 

Setup Requirements

  • Need to set up an AWS Account
  • (Most of the Services comes with AWS free tier eligibility)
  • Windows: Putty, Putty KeyGen and Web Browser with Internet connectivity.
  • Linux/Mac : DefaultTerminal

AWS Training Course Overview

Introduction to Cloud Computing

  • Introduction to cloud computing
  • Essential Characteristics of Cloud Computing
  • Service Models in Cloud computing
  • Deployment models in Cloud Computing
  • Introduction to AWS
  • AWS Account creation &free tier limitations overview 

Identity Access Management

  • Root Account Vs IAM user
  • Multi Factor Authentication for Users
  • Password Policies 

Storage

  • What is Simple Storage Service (S3)
  • Storage Classes
  • Versioning
  • Life Cycle Management &
  • Content Delivery Networks (Cloud Front)
  • Security & Encryption
  • Static Webhosting with S3 bucket
  • Storage Gateway 

Compute

  • Launch EC2 Instances
  • EC2 Instance Types
  • Security groups
  • Volumes and Snapshots
  • RAID Overview and RAID Configuration on windows
  • Creating an Amazon Machine Images
  • Bootstrap scripting
  • ElasticLoad Balancers & Health Checks
  • Auto Scaling Groups
  • Cloud Watch
  • AWS CLI
  • EC2 Roles
  • Metadata
  • Elastic File System
  • AWS Lightsail
  • Elastic Beanstalk 

Route 53

  • DNS Records overview
  • Routing Policies
  • Hosting sample Website

Databases

  • Launching a RDS Instance
  • Backups, Multi-AZ & Read Replicas
  • DynamoDB
  • Redshift
  • Elastichache
  • Amazon Aurora

Networking

  • Basics of Networking
  • Creating custom VPC 

Application Services

  • Simple Email Service
  • Simple Queue Service
  • Simple Workflow Service
  • Simple Notification Service
  • ElasticTranscoder
  • Trusted Advisor 

AWS Services &Backups 

  • Disaster Recovery 

Developer Tools Overview (Optional)

  • Code Pipeline, Code Commit, Code Build and Code Deploy.
  • Cloud Formation
  • Lambda