Ruby Script by AWS for Identity Federation

#!/usr/bin/ruby require ‘rubygems’ require ‘json’ require ‘open-uri’ require ‘cgi’ require ‘aws-sdk’ # The temporary credentials will normally come from your identity # broker, but for simplicity we create them in place sts = AWS::STS.new(:access_key_id => “AKFFAASVASDE”, :secret_access_key => “irJa8tNsdfavaercravavraWA”) # A sample policy for accessing SNS in the console. policy = AWS::STS::Policy.new policy.allow(:actions => “*”,:resources […]

AS Monitoring-Svr Script

#!/bin/bash while true do rm req-values #Get instance list as-describe-auto-scaling-groups unni-autoscale-test | awk {‘print $2’} | grep -v unni-autoscale-test > inst-list #retrieving public ip address from the instance address for i in `cat /home/unni/as-test/inst-list`; do ec2-describe-instances $i  | awk ‘{print $4}’ | grep amazonaws.com >> ip-list done #retrieving access log values for i in `cat […]

Create an AMI of EBS-backed-Instance for backup

This is an excerpt from script running on an chef build debian ec2 instance. OS – Debain Squeeze Assuming EC2-API tools are installed and configured. Also the export the environment variable (to avoid using -C and -K flags in command) export EC2_PRIVATE_KEY=/root/ec2-certs/pk-47OH3YSOZRKGXYH4P2MXKW6YDEKOHGGV.pem export EC2_CERT=/root/ec2-certs/cert-47OH3YSOZRKGXYH4P2MXKW6YDEKOHGGV.pem ###### To obtain instance ID ######### #inst_id=`cat /opt/smart/log.txt | grep Instance […]

Take EBS Snapshot with 3 days of rentention

NOTE: This script was created for Chef build instances, so the log(/opt/log.txt) which takes the stdout output is the source where the instance id is fetched from. Also a 50GB EBS is also attached on the fly by CHEF #!/bin/bash C=`date +%Y-%m-%d –date=’3 days ago’` ###### To obtain instance ID ######### inst_id=`cat /opt/log.txt | grep […]