Skip to content

Instantly share code, notes, and snippets.

View kthallam's full-sized avatar

Krishna Kireeti Thallam kthallam

  • Hyderabad, India
View GitHub Profile
@kthallam
kthallam / autoscaling_update.sh
Created January 22, 2020 15:45
How to update the launch configuration for the existing auto scaling group
#!/bin/bash
# Name of the autosacling group need to replaced with keyworkd in the script
autoscaling_name=`aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[].[AutoScalingGroupName]' --output=text | grep -i <Name of the autosacling group>`
echo $autoscaling_name
launchconfig_name=`aws autoscaling describe-auto-scaling-groups --auto-scaling-group-name $autoscaling_name --output=json | grep -m1 LaunchConfigurationName | cut -d ":" -f 2| sed 's/"//g'`
echo $launchconfig_name
security_group_id=`aws autoscaling describe-launch-configurations --launch-configuration-names $launchconfig_name | grep sg- |awk '{print $1}'| sed 's/"//g'`
echo $security_group_id
amiid=`aws autoscaling describe-launch-configurations --launch-configuration-names $launchconfig_name | grep ami |cut -d ":" -f 2 | sed 's/"//g'| sed 's/,//g'`
echo $amiid
@kthallam
kthallam / aws_s3_tags.sh
Created September 27, 2019 08:57
Find the List of S3 buckets does not have a specific tag value.
# Modify <Key/Value that need be searched> that you want to search
#!/bin/bash
declare -a test
test=(`aws s3 ls | awk -F ' ' '{print $3}'`)
i=0
while [ $i -lt ${#test[@]} ]
do
a=`aws s3api get-bucket-tagging --bucket ${test[$i]}| grep -w <Key/Value that need be searched> 2>/dev/null`
if [ -z "$a" ]
then
@kthallam
kthallam / aws_es_tags_finder.sh
Last active September 26, 2019 13:33
Script to find the elastic cache services that are not tagged with the specific tag in aws
#!/bin/bash
declare -a test
test=(`aws elasticache describe-cache-clusters | grep CacheClusterId | awk -F '"' '{print $4}'`)
i=0
while [ $i -lt ${#test[@]} ]
do
a=`aws elasticache list-tags-for-resource --resource-name arn:aws:elasticache:<Region>:<Account ID>:cluster:${test[$i]}| grep -w <KEY/Value of Tag >`
if [ -z "$a" ]
then
echo "${test[$i]} does not have tag "
@kthallam
kthallam / array_rotation.rb
Created September 4, 2018 18:09
Rotation of an array in ruby
def rotatearray
puts "How Many time to rotate the array in clock wise"
times = gets.chomp.to_i
a = []
puts "Enter the size of array"
size = gets.chomp.to_i
puts "Enter the values into array one by one"
for i in 0..size-1
i = gets.chomp.to_i
a << i
@kthallam
kthallam / file_operations.rb
Last active September 2, 2018 14:45
Ruby script to find out the top 3 ips from which is traffic is coming to your server.
# This Script will help you to find the top 3 ips from which is traffic is coming to your servers
# Assuming log file is in this format "<IP Address> <Time Stamp> <url requested> <Rest Service Call Method > < Response>"
def file_operations(file)
str = Array.new
temp = Array.new
File.open(file).each do |line|
str << line.match(" ").pre_match
end
str.uniq.each do |a|
temp << "#{str.count(a.chomp)} #{a}"
@kthallam
kthallam / Prime_Numbers.rb
Created September 1, 2018 19:49
Prime Number Program in Ruby
def primenumber(x)
temp = true
for i in 2..x/2
if x%i == 0
temp = false
break
end
end
if temp == true
puts "#{x} is a Prime Number"