Advertisement

Showing posts with label EC2. Show all posts
Showing posts with label EC2. Show all posts

Thursday, January 30, 2020

Amazon Web Services (AWS) : EC2 - Instance Metadata Get Region/Type/IP

In this blog I am going to demonstrate how to get the Instance Metadata information using curl.

Instance Metadata information is available at the 169.254.169.254 IP address.
If you are from networking background you will realize, this is Automatic Private IP or Self Assigned Private IP.

So, we use curl to get the information and as an example below. 



$ curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | grep -e Type -e region -e Ip
  "instanceType" : "m5.2xlarge",
  "privateIp" : "10.114.32.79",
  "region" : "us-east-1",

Tuesday, September 3, 2019

Amazon Web Services (AWS) : Placement Groups

In this blog, I am going to discuss an important new features which AWS has released which is called as placement groups. 

So, what are placement groups.
Placement groups are basically directives given to AWS Kernel to place your EC2 instances at specific locations. 
And what are these locations
- specific AZ
- specific RAC
- Zone based
and etc

So, As of now (Sep -2019), AWS has come up with 3 types of placement groups 

  1. Cluster
  2. Spread
  3. Groups
Let's see what is what 
Cluster - Cluster Placement Group is basically a directive to launch EC2 instances within the same Rack.
Visualize thousands of servers placed in Amazon Data Centers and they are placed in different racks, so when you give 'Cluster' as placement group, all the instances will be launched within the same RAC (in same AZ).
Pros 
  1. Great in terms of networking (10Gbps between 2 instances)
  2. Gives low latency and high n/w throughput
  3. Jobs such as Big data benefit 

Cons 
There is one big issue, if the RAC fails, you loose all the instances. 


Spread
Now visualize within all the data centers and you want to distribute your highly available application within multiple data centers, so spread helps you with that - with instances spanning multiple AZs and different physical RAC if in the same AZ.

Pros 

  1. Reduced Risk in terms of failure
  2. All the instances are on different physical hardware 
  3. Provides High Availability for critical applications
Cons
  1. You are limited to 7 instances per AZ per placement group. 

Partition
Within one AZ , span  multiple partitions, and what is partition, an isolation created by AWS in their data centers which is a physical boundary and ensures one partition's availability does not affects others. 

Pros
  1. Instances do not share racks with other instances
  2. Safe from partition failure
  3. EC2 instance get access to partition information as metadata
  4. Can spawn 100s of instances
Cons
  1. The limitation put by AWS (as of now) is 7 partitions per AZ

Wednesday, August 28, 2019

Amazon Web Services (AWS) : EC2-User Data

EC2 - user data is one of the seldom used features, yet a powerful feature. 
It is basically a simple script which can is executed at boot time by the system, the script has sudo 

It can be used for - 
• Installing updates
• Installing software
• Downloading common files from the internet

• Anything you can think of

It is configured in Advanced section of the Instance Launch Page. 

Below is an example of apache Service install and launch using an ec2-script. 

#!/bin/bash yum update -y
yum install -y httpd.x86_64
systemctl start httpd.service
systemctl enable httpd.service

echo "Heloo World" > /var/www/html/index.html/index.html


The greatest of the use of EC2-user data is when using load balancing, starting parallel instances and any boot time action you want to perform (manually or automatically).

Remember - the header #!/bin/bash is mandatory and without it your script will not work.