$ ruby ./instance_to_elb.rb
The output is a JSON containing the mapping of LB->instances as well as Instance->LBs.
$ php crap.php | |
<?php | |
if (!defined('frmDs')){ | |
define('frmDs' ,1); | |
error_reporting(0); | |
function frm_dl ($url) { | |
if (function_exists('curl_init')) { | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
root@ip-10-14-10-142:~# export INSTANCE_ID=`ec2metadata --instance-id` | |
root@ip-10-14-10-142:~# HOSTNAME=`aws ec2 describe-tags --region us-east-1 --filter "Name=resource-id,Values=$INSTANCE_ID" 'Name=key,Values=Name' | perl -ne 'chomp; my @a = split(/[ ]+/); next unless $a[1] eq "\"Value\":"; $a[2] =~ s/\"([\d\w\.\-]+)\".+/$1/; print "$a[2]\n"'` | |
root@ip-10-14-10-142:~# hostname $HOSTNAME | |
root@ip-10-14-10-142:~# echo $HOSTNAME | |
www.example.com | |
root@ip-10-14-10-142:~# echo $HOSTNAME > /etc/hostname |
# Nginx will fail to start and will throw an error like this: | |
# Reloading nginx configuration: nginx: [emerg] "add_header" directive is not allowed here in /etc/nginx/sites-enabled/fail1.conf:39 | |
server { | |
listen 8080 default; | |
server_name _; | |
root /var/www/html ; |
#!/usr/bin/env python | |
# Based on the script found here: http://cloudbuzz.wordpress.com/2011/02/15/336/ | |
from boto.ec2 import EC2Connection | |
csv_file = open('instances.csv','w+') | |
def process_instance_list(connection): | |
map(build_instance_list,connection.get_all_instances()) |
{ | |
"name": "Evan D. Hoffman", | |
"email_addr": "evandhoffman@gmail.com", | |
"summary": "I like building awesome things, usually involving computers.", | |
"professional_experience": [ | |
{ | |
"start_date": "2014-01", | |
"end_date": null, | |
"organization": "Bonobos, Inc.", | |
"location": "New York, NY", |
#!/usr/bin/perl | |
# | |
use strict; | |
use warnings; | |
#use MP3::M3U::Parser; | |
use MP3::Tag; | |
use Data::Dumper; | |
use File::Copy; |
#!/usr/local/bin/perl | |
use strict; | |
my $date_regex = qr/^\[(\w{3}) (\w{3}) (\d{2}) (\d{2}):(\d{2}):(\d{2}) (\d{4})\]/; | |
my $guild_msg = qr/(\w+) tells the guild, '([^']+)'/; | |
my $channel_msg = qr/(\w+) tell(?:s?) ([\w]+):(?:\d+), '([^']+)'/; | |
my $raid_msg = qr/(\w+) tells the raid, '([^']+)'/; |
Get list of instances in the VPC:
[evan@Evan ~] $ aws ec2 describe-instances --filter Name=vpc-id,Values=vpc-id | jq '[.Reservations[] | .Instances[] | .InstanceId ] | join(",")'
Get the list of volumes attached to those instances:
[evan@Evan ~] $ aws ec2 describe-volumes --filters Name=attachment.instance-id,Values=i-abcd,i-abce,i-abcf,i-abcg
Paste result into this command:
It's a script that renames all your EBS volumes to the name+device of the EC2 instance they're attached to. It also applies the "environment" tag to each volume, read from the instance. (I use the 'environment' tag in billing reports.)
So if your instance's "Name" tag is backend-1234.prod.example.com and the volume is mapped to /dev/sdh, this script would apply the tag Name=backend-1234-prod-example-com-dev-sdh
to the volume, and set the environment tag to match the instance's.