Wednesday, November 30, 2016

Public and Private subnets in AWS

If a subnet's traffic is routed to Internet Gateway, the subnet is known as public subnet

If a subnet doesn't have a route to the Internet gateway, the subnet is known as private subnet

The machines in private subnet can access internet through NAT gateway(instance). A NAT instance is an instance on public subnet and has a public IP address.

Can instances in private subnet have public IP addresses?

Yes, public IP address can be assigned to instances in private subnet. But it is of no use.
Inbound traffic from the Internet would hit the public IP of the instance, but the replies would try to route outward through the NAT instance, which would either drop the traffic (since it would be composed of replies to connections it's not aware of, so they'd be deemed invalid) or would rewrite the reply traffic to use its own public IP address, which wouldn't work since the external origin would not accept replies that came from an IP address other than the one they were trying to initiate communications with.

Why create subnets in AWS VPC?

When you create a VPC, it spans all of the Availability Zones in the region. After creating a VPC, you can add one or more subnets in each Availability Zone. When you create a subnet, you specify the CIDR block for the subnet, which is a subset of the VPC CIDR block. 

Each subnet must reside entirely within one Availability Zone and cannot span zones. 

Availability Zones are distinct locations that are engineered to be isolated from failures in other Availability Zones. By launching instances in separate Availability Zones, you can protect your applications from the failure of a single location. We assign a unique ID to each subnet.

Thursday, February 11, 2016

Install Jenkins plugins from command line including dependencies

To install Jenkins plugins from command line, including dependencies, run the following

curl -X POST -d '<jenkins><install plugin="plugin-name@latest" /></jenkins>' --header 'Content-Type: text/xml' http://localhost:8080/pluginManager/installNecessaryPlugins

where,
        - replace plugin-name with plugin to be installed
        - http://localhost:8080 is the URL where Jenkins service is available. Replace it with your Jenkins url path
       - @latest refers to the latest version of the plugin

Alternatively, one can try the following script too

   https://gist.github.com/micw/e80d739c6099078ce0f3

How to find the Jenkins plugins installed?

Suppose Jenkins  is available under the http url, http://localhost:8080, we can determine the plugins installed for Jenkins as follows

 java -jar jenkins-cli.jar -s http://localhost:8080 list-plugins

How to download Oracle JDK rpm and install?

To install Oracle JDK, download the rpm as follows

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.rpm"

How to find the Java(JVM) version used by Tomcat?

To find the Java(JVM) version used by Tomcat, when we observe multiple jdks installed in the system

Go to Tomcat service home directory and run the following command

java -cp lib/catalina.jar org.apache.catalina.util.ServerInfo

Monday, December 28, 2015

AWS Cloudformation : Intrinsic Functions

AWS Cloudformation templates have Intrinsic functions to use upon on Resources such as properties and metadata attributes



String Handling Functions

Fn::Base64 - Returns the Base64 representation of the input string. This function is typically used to pass encoded data to Amazon EC2 instances by way of the UserData property.

Fn::Join - Appends a set of values into a single value, separated by the specified delimiter. If a delimiter is the empty string, the set of values are concatenated with no delimiter.

Functions for Managing data and variables inside the Template


Fn::FindInMap Returns the value corresponding to keys in a two-level map that is declared in the Mappings section.

Fn::GetAtt Returns the value of an attribute from a resource in the template.

Ref Returns the value of the specified parameter or resource.

Region Selection Function


Fn::GetAZs Returns an array that lists Availability Zones for a specified region.