Skip to content

Instantly share code, notes, and snippets.

View scalp42's full-sized avatar
🪂

Anthony Scalisi scalp42

🪂
View GitHub Profile

To use this snippet first replace the _default in the URL with your environment name if you are using somethign other than the global default. Next in the run list, replace ... with your cookbook names. Unlike other run lists, you cannot have roles here, and you don't use the 'recipe[foo]' syntax, just 'foo'.

#!/bin/sh
# Get crazy throughput if you do this (>5000 puts/sec)
#
# What some customers have done is something like this: say this is the filename:
#
# mybucket/17476/26466/16.png
#
# Then to get the hash do something that seems silly but works great (pretty
# much any two characters from the hash will work):
#
#
# Sample nginx.conf optimized for EC2 c1.medium to xlarge instances.
# Also look at the haproxy.conf file for how the backend is balanced.
#
user "nginx" "nginx";
worker_processes 10;
error_log /var/log/nginx_error.log info;
  1. Create the appropriate VPC that your application is going to live in. Create subnets for each availability zone you want to use.

  2. Create VPC security group(s) for your auto-scaling instances. For example, if you're going to auto-scale web servers, create a "web" VPC security group.

  3. Go into AWS console and create an ELB. Easy wizard. Select HTTP and (if needed) HTTPS. Make sure it's associated with the VPC you created in step 1.

  4. Create an auto-scaling launch configuration from the CLI. The launch configuration has the AMI, size, and security group from step #2. The security group must be by ID not name ("sg-12345"):

       as-create-launch-config web --image-id ami-2e31bf1e --instance-type m1.medium \
    

-g sg-7619041a --key root

#
# This config file is a combination of ideas from:
# http://www.37signals.com/svn/posts/1073-nuts-bolts-haproxy
# http://www.igvita.com/2008/05/13/load-balancing-qos-with-haproxy/
# http://wiki.railsmachine.com/HAProxy
# http://elwoodicious.com/2008/07/15/nginx-haproxy-thin-fastcgi-php5-load-balanced-rails-with-php-support/
# http://upstream-berlin.com/2008/01/09/using-haproxy-with-multiple-backends-aka-content-switching/
# http://wiki.railsmachine.com/HAProxy
# http://gist.github.com/raw/25482/d39fb332edf977602c183194a1cf5e9a0b5264f9
#
@scalp42
scalp42 / Gemfile
Created March 23, 2014 23:38 — forked from gorenje/Gemfile
source :rubygems
gem 'sinatra'
gem 'json'
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-github'
gem 'omniauth-facebook'
gem 'omniauth-twitter'
# gem 'omniauth-att', :path => File.expand_path("./../../omniauth-att", __FILE__)
@scalp42
scalp42 / Gemfile
Created March 23, 2014 23:38 — forked from fairchild/Gemfile
source :rubygems
gem 'sinatra'
gem 'json'
gem 'omniauth'
gem 'omniauth-oauth2'
gem 'omniauth-github'
# gem 'omniauth-att', :path => File.expand_path("./../../omniauth-att", __FILE__)
gem 'thin'
#!/bin/sh
domain=$1
wait=$2
if [ "$domain" = "" ]
then
domain=standard
else
domain_option="-d $domain"
fi
if [ "$wait" = "" ]
#!/bin/sh
perl -v > /dev/null || exit 1
m()
{
curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/$1
}
for mac in `m`
do
dev=`m $mac/device-number`
#!/bin/zsh
VPCID=$(ec2addvpc 10.100.0.0/16 | cut -f 2 ) && sleep 30 | SUBNETA=$(ec2addsubnet -c $VPCID -i 10.100.1.0/24 -z ap-northeast-1a| cut -f 2) && SUBNETB=$(ec2addsubnet -c $VPCID -i 10.100.2.0/24 -z ap-northeast-1b| cut -f 2) && IGW=$(ec2addigw | cut -f 2) && sleep 15 | ec2attigw $IGW -c $VPCID | RTB=$(ec2drtb | grep $VPCID | cut -f 2) | ec2assocrtb $RTB -s $SUBNETA | ec2addrt $RTB -r 0.0.0.0/0 -g $IGW | INSAID=$(ec2run ami-4e6cd34f -k keypair -t t1.micro -s $SUBNETA | grep ^INSTANCE | cut -f 2) && INSBID=$(ec2run ami-4e6cd34f -k keypair -t t1.micro -s $SUBNETB | grep ^INSTANCE | cut -f 2) && EIPASSOS=$(ec2allocaddr -d vpc | cut -f 5) && SG=$(ec2dgrp | grep $VPCID | cut -f 2) && ec2auth $SG -P TCP -p 22 | sleep 30 | ec2assocaddr -a $EIPASSOS -i $INSAID --allow-reassociation | echo DONE!