Compute and Networking Services for AWS


AWS provides a variety of computing and networking services to meet the needs of your applications.You can provision virtual servers, set up a firewall, configure Internet access, allocate and route IP addresses, and scale your infrastructure to meet increasing demand.



You can use the compute and networking services with the storage, database, and application services to provide a complete solution for computing, query processing, and storage across a wide range of applications.


Contents

  • Key Services
  • Key Concepts
  • Architecture



Key Services


The following are the key compute and networking services:

Amazon EC2
Provides virtual servers in the AWS cloud.

Amazon VPC
Provides an isolated virtual network for your virtual servers.

Elastic Load Balancing
Distributes network traffic across your set of virtual servers.

Auto Scaling
Automatically scales your set of virtual servers based on changes in demand.

Amazon Route 53
Routes traffic to your domain name to a resource, such as a virtual server or a load balancer.

AWS Lambda
Runs your code on virtual servers from Amazon EC2 in response to events.

Amazon ECS
Provides Docker containers on virtual servers from Amazon EC2.




Key Concepts

The following are concepts that you should understand before using the compute and networking services.

Instances and AMIs

Amazon Elastic Compute Cloud (Amazon EC2) provides resizeable computing capacity—literally, servers in Amazon's data centers—that you use to build and host your software systems. An Amazon Machine Image (AMI) is a template that contains a software configuration (for example, an operating system, an application server, and applications). From an AMI, you launch an instance, which is a copy of the AMI running as a virtual server on a host computer in Amazon's data center. You can launch multiple instances from an AMI, as shown in the following figure.
















When you launch an instance, you select an instance type, which determines the hardware capabilities  (such as memory, CPU, and storage) of the host computer for the instance. You can access your instance using its assigned public DNS name or public IP address. The public DNS names for instances are as follows:

The US East (N. Virginia) region
ec2-public_ip.compute-1.amazonaws.com

Other regions
ec2-public_ip.region_code.compute.amazonaws.com

Your instances keep running until you stop or terminate them, or until they fail. If an instance fails, you can launch a new one from the AMI.
You start from an existing AMI that most closely meets your needs, log on to the instance, and then customize the instance with additional software and settings. You can save this customized configuration as a new AMI, which you can then use to launch new instances whenever you need them.




VPCs and Subnets

A virtual private cloud (VPC) is a virtual network dedicated to your AWS account. It is logically isolated from other virtual networks in the AWS cloud, providing security and robust networking functionality for your compute resources. A VPC closely resembles a traditional network that you'd operate in your own data center, with the benefits of using the scalable infrastructure of AWS.

A subnet is a segment of a VPC's IP address range that you can launch instances into. Subnets enable you to group instances based on your security and operational needs. To enable instances in a subnet to reach the Internet and AWS services, you must add an Internet gateway to the VPC and a route table with a route to the Internet to the subnet.
We recommend that you launch your EC2 instances into a VPC. Note that if you created your AWS account after 2013-12-04, you have a default VPC and you must launch EC2 instances into a default or a nondefault VPC.




Security Groups

A security group acts as a virtual firewall for your instance to control inbound and outbound traffic. You can specify one or more security groups when you launch your instance. When you create a security group, you add rules that control the inbound traffic that's allowed, and a separate set of rules that control the outbound traffic. All other traffic is discarded. You can modify the rules for a security group at any time and the new rules are automatically enforced.



























AWS

 Getting Started with AWS





Amazon Web Services (AWS) provides on-demand computing resources and services in the cloud, with pay-as-you-go pricing. For example, you can run a server on AWS that you can log on to, configure, secure, and run just as you would a server that's sitting in front of you. For more information, see What is Cloud Computing?



What Can I Do with AWS?


You can use AWS to make it easier to build and manage your websites and applications. The following are some common uses for AWS:


• Store public or private data.

• Host a static website. These websites use client-side technologies (such as HTML, CSS, and JavaScript) to display content that doesn't change frequently. A static website doesn't require serverside technologies (such as PHP and ASP.NET).

• Host a dynamic website, or web app. These websites include classic three-tier applications, with

web, application, and database tiers.

• Support students or online training programs.

• Process business and scientific data.

• Handle peak loads.



How Do I Access AWS?


AWS provides several ways to create and manage resources.


AWS Management Console

A web interface. To get started, see the Getting Started with the AWS Management Console.


AWS Command Line Interface (AWS CLI)

Commands for a broad set of AWS products. To get started, see AWS Command Line Interface User Guide.


Command Line Tools

Commands for individual AWS products. For more information, see Command Line Tools.


AWS Software Development Kits (SDK)

APIs that are specific to your programming language or platform. For more information, see

SDKs.


Query APIs

Low-level APIs that you access using HTTP requests. For more information, see the API

documentation for each service.




AWS Overview

Linux Cheat Sheet

 Linux Command Line Cheat Sheet







Table of Contents


  1. System Information
  2. Hardware Information
  3. Performance Monitoring and Statistics
  4. User Information and Management
  5. File and Directory Commands
  6. Process Management
  7. File Permission
  8. Networking
  9. Archives
  10. Installing Packages
  11. Search 
  12. SSH Logins
  13. FIle Transfer
  14. Disk Usage
  15. Directory Navigation





1

Java - Object and Classes




Java is an Object-Oriented Language. As a language that has the Object-Oriented feature, Java supports the following fundamental concepts −


  • Polymorphism
  • Inheritance
  • Encapsulation
  • Abstraction
  • Classes
  • Objects
  • Instance
  • Method
  • Message Passing

In this chapter, we will look into the concepts - Classes and Objects.

  • Object − Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors – wagging the tail, barking, eating. An object is an instance of a class.

  • Class − A class can be defined as a template/blueprint that describes the behavior/state that the object of its type support.

Objects in Java

Let us now look deep into what are objects. If we consider the real-world, we can find many objects around us, cars, dogs, humans, etc. All these objects have a state and a behavior.

If we consider a dog, then its state is - name, breed, color, and the behavior is - barking, wagging the tail, running.

If you compare the software object with a real-world object, they have very similar characteristics.

Software objects also have a state and a behavior. A software object's state is stored in fields and behavior is shown via methods.

So in software development, methods operate on the internal state of an object and the object-to-object communication is done via methods.

Classes in Java

A class is a blueprint from which individual objects are created.

Following is a sample of a class.


Example

public class Dog {
   String breed;
   int age;
   String color;

   void barking() {
   }

   void hungry() {
   }

   void sleeping() {
   }
}


A class can contain any of the following variable types.

  • Local variables − Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed.

  • Instance variables − Instance variables are variables within a class but outside any method. These variables are initialized when the class is instantiated. Instance variables can be accessed from inside any method, constructor or blocks of that particular class.

  • Class variables − Class variables are variables declared within a class, outside any method, with the static keyword.



Constructors

When discussing about classes, one of the most important sub topic would be constructors. Every class has a constructor. If we do not explicitly write a constructor for a class, the Java compiler builds a default constructor for that class.


Example

public class Puppy {
   public Puppy() {
   }

   public Puppy(String name) {
      // This constructor has one parameter, name.
   }
}


Note − We have two different types of constructors. We are going to discuss constructors in detail in the subsequent chapters.

Creating an Object

As mentioned previously, a class provides the blueprints for objects. So basically, an object is created from a class. In Java, the new keyword is used to create new objects.

There are three steps when creating an object from a class −

  • Declaration − A variable declaration with a variable name with an object type.

  • Instantiation − The 'new' keyword is used to create the object.

  • Initialization − The 'new' keyword is followed by a call to a constructor. This call initializes the new object.

Following is an example of creating an object −


public class Puppy {
   public Puppy(String name) {
      // This constructor has one parameter, name.
      System.out.println("Passed Name is :" + name );
   }

   public static void main(String []args) {
      // Following statement would create an object myPuppy
      Puppy myPuppy = new Puppy( "tommy" );
   }
}



Output

Passed Name is :tommy



Advantages of OOPS:


  • OOP offers easy to understand and a clear modular structure for programs.
  • Objects created for Object-Oriented Programs can be reused in other programs. Thus it saves significant development cost.
  • Large programs are difficult to write, but if the development and designing team follow OOPS concept then they can better design with minimum flaws.
  • It also enhances program modularity because every object exists independently.


Java Identifiers




All Java components require names. Names used for classes, variables, and methods are called identifiers.

In Java, there are several points to remember about identifiers. They are as follows −

  • All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an underscore (_).

  • After the first character, identifiers can have any combination of characters.

  • A key word cannot be used as an identifier.

  • Most importantly, identifiers are case sensitive.

  • Examples of legal identifiers: age, $salary, _value, __1_value.

  • Examples of illegal identifiers: 123abc, -salary.

Java Modifiers

Like other languages, it is possible to modify classes, methods, etc., by using modifiers. There are two categories of modifiers −

  • Access Modifiers − default, public , protected, private

  • Non-access Modifiers − final, abstract, strictfp

We will be looking into more details about modifiers in the next section.


Java Variables

Following are the types of variables in Java −

  • Local Variables
  • Class Variables (Static Variables)
  • Instance Variables (Non-static Variables)

Java Arrays

Arrays are objects that store multiple variables of the same type. However, an array itself is an object on the heap. We will look into how to declare, construct, and initialize in the upcoming chapters.

Java Enums

Enums were introduced in Java 5.0. Enums restrict a variable to have one of only a few predefined values. The values in this enumerated list are called enums.



Example

class FreshJuice {
   enum FreshJuiceSize{ SMALL, MEDIUM, LARGE }
   FreshJuiceSize size;
}

public class FreshJuiceTest {

   public static void main(String args[]) {
      FreshJuice juice = new FreshJuice();
      juice.size = FreshJuice.FreshJuiceSize.MEDIUM ;
      System.out.println("Size: " + juice.size);
   }
}



The above example will produce the following result −

Output

Size: MEDIUM

Note − Enums can be declared as their own or inside a class. Methods, variables, constructors can be defined inside enums as well


Java Keywords

The following list shows the reserved words in Java. These reserved words may not be used as constant or variable or any other identifier names.



abstractassertbooleanbreak
bytecasecatchchar
classconstcontinuedefault
dodoubleelseenum
extendsfinalfinallyfloat
forgotoifimplements
importinstanceofintinterface
longnativenewpackage
privateprotectedpublicreturn
shortstaticstrictfpsuper
switchsynchronizedthisthrow
throwstransienttryvoid
volatilewhile



Comments in Java

Java supports single-line and multi-line comments very similar to C and C++. All characters available inside any comment are ignored by Java compiler.




public class MyFirstJavaProgram {

   /* This is my first java program.
    * This will print 'Hello World' as the output
    * This is an example of multi-line comments.
    */

   public static void main(String []args) {
      // This is an example of single line comment
      /* This is also an example of single line comment. */
      System.out.println("Hello World");
   }
}


Output

Hello World



Using Blank Lines

A line containing only white space, possibly with a comment, is known as a blank line, and Java totally ignores it.

Inheritance

In Java, classes can be derived from classes. Basically, if you need to create a new class and here is already a class that has some of the code you require, then it is possible to derive your new class from the already existing code.

This concept allows you to reuse the fields and methods of the existing class without having to rewrite the code in a new class. In this scenario, the existing class is called the superclass and the derived class is called the subclass.

Interfaces

In Java language, an interface can be defined as a contract between objects on how to communicate with each other. Interfaces play a vital role when it comes to the concept of inheritance.

An interface defines the methods, a deriving class (subclass) should use. But the implementation of the methods is totally up to the subclass.






Java Basics Syntax

 



When we consider a Java program, it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what do class, object, methods, and instance variables mean.

  • Object − Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behavior such as wagging their tail, barking, eating. An object is an instance of a class.

  • Class − A class can be defined as a template/blueprint that describes the behavior/state that the object of its type supports.

  • Methods − A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed.

  • Instance Variables − Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables.


First Java Program


public class MyFirstJavaProgram {

   /* This is my first java program.
    * This will print 'Hello World' as the output
    */

   public static void main(String []args) {
      System.out.println("Hello World"); // prints Hello World
   }
}

Let's look at how to save the file, compile, and run the program. Please follow the subsequent steps −

  • Open notepad and add the code as above.

  • Save the file as: MyFirstJavaProgram.java.

  • Open a command prompt window and go to the directory where you saved the class. Assume it's C:\.

  • Type 'javac MyFirstJavaProgram.java' and press enter to compile your code. If there are no errors in your code, the command prompt will take you to the next line (Assumption : The path variable is set).

  • Now, type ' java MyFirstJavaProgram ' to run your program.

You will be able to see ' Hello World ' printed on the window.


Output

C:\> javac MyFirstJavaProgram.java
C:\> java MyFirstJavaProgram 
Hello World

Basic Syntax

About Java programs, it is very important to keep in mind the following points.

  • Case Sensitivity − Java is case sensitive, which means identifier Hello and hello would have different meaning in Java.

  • Class Names − For all class names the first letter should be in Upper Case. If several words are used to form a name of the class, each inner word's first letter should be in Upper Case.

    Example: class MyFirstJavaClass

  • Method Names − All method names should start with a Lower Case letter. If several words are used to form the name of the method, then each inner word's first letter should be in Upper Case.

    Example: public void myMethodName()

  • Program File Name − Name of the program file should exactly match the class name.

Java Local Environment Setup





 Java Installation

If you are still willing to set up your environment for Java programming language, then this section guides you on how to download and set up Java on your machine. Following are the steps to set up the environment.

Java SE is freely available from the link Download Java. You can download a version based on your operating system.

Follow the instructions to download Java and run the .exe to install Java on your machine. Once you installed Java on your machine, you will need to set environment variables to point to correct installation directories −



Setting Up the Path for Windows


Assuming you have installed Java in c:\Program Files\java\jdk directory −

  • Right-click on 'My Computer' and select 'Properties'.

  • Click the 'Environment variables' button under the 'Advanced' tab.

  • Now, alter the 'Path' variable so that it also contains the path to the Java executable. Example, if the path is currently set to 'C:\WINDOWS\SYSTEM32', then change your path to read 'C:\WINDOWS\SYSTEM32;c:\Program Files\java\jdk\bin'.





Setting Up the Path for Linux, UNIX, Solaris, FreeBSD

Environment variable PATH should be set to point to where the Java binaries have been installed. Refer to your shell documentation, if you have trouble doing this.

Example, if you use bash as your shell, then you would add the following line to the end of your '.bashrc: export PATH = /path/to/java:$PATH'




Popular Java Editors

To write your Java programs, you will need a text editor. There are even more sophisticated IDEs available in the market. But for now, you can consider one of the following −

  • Notepad − On Windows machine, you can use any simple text editor like Notepad (Recommended for this tutorial), TextPad.

  • Netbeans − A Java IDE that is open-source and free which can be downloaded from https://www.netbeans.org/index.html.

  • Eclipse − A Java IDE developed by the eclipse open-source community and can be downloaded from https://www.eclipse.org/.

Ansible Hands-on

  what is Ansible It's a simple automation language that can perfectly describe  an IT application infrastructure in Ansible Playbooks. ...