Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Scripting creating AWS based servers
Search
coldclimate
January 27, 2014
Technology
0
270
Scripting creating AWS based servers
in the most Taco Bell way I know
coldclimate
January 27, 2014
Tweet
Share
More Decks by coldclimate
See All by coldclimate
You don't scale like servers scale
coldclimate
0
130
Quick and dirty load testing with Vegeta
coldclimate
3
4.1k
Continuously deploying https served statically compiled sites to S3 with canonical domains
coldclimate
0
71
Scaling CANDDi
coldclimate
0
250
refactoring
coldclimate
1
130
Other Decks in Technology
See All in Technology
TAMとre:Capセキュリティ編 〜拡張脅威検出デモを添えて〜
fujiihda
2
250
Goで作って学ぶWebSocket
ryuichi1208
3
1.5k
君も受託系GISエンジニアにならないか
sudataka
2
440
急成長する企業で作った、エンジニアが輝ける制度/ 20250214 Rinto Ikenoue
shift_evolve
3
1.3k
SA Night #2 FinatextのSA思想/SA Night #2 Finatext session
satoshiimai
1
140
Raycast AI APIを使ってちょっと便利な拡張機能を作ってみた / created-a-handy-extension-using-the-raycast-ai-api
kawamataryo
0
100
RECRUIT TECH CONFERENCE 2025 プレイベント【高橋】
recruitengineers
PRO
0
160
インフラをつくるとはどういうことなのか、 あるいはPlatform Engineeringについて
nwiizo
5
2.6k
利用終了したドメイン名の最強終活〜観測環境を育てて、分析・供養している件〜 / The Ultimate End-of-Life Preparation for Discontinued Domain Names
nttcom
2
200
組織貢献をするフリーランスエンジニアという生き方
n_takehata
2
1.3k
技術的負債解消の取り組みと専門チームのお話 #技術的負債_Findy
bengo4com
1
1.3k
レビューを増やしつつ 高評価維持するテクニック
tsuzuki817
1
730
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
44
13k
We Have a Design System, Now What?
morganepeng
51
7.4k
Documentation Writing (for coders)
carmenintech
67
4.6k
Designing for humans not robots
tammielis
250
25k
Facilitating Awesome Meetings
lara
52
6.2k
Side Projects
sachag
452
42k
Writing Fast Ruby
sferik
628
61k
Rails Girls Zürich Keynote
gr2m
94
13k
Done Done
chrislema
182
16k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Transcript
Scripting your servers @coldclimate CANDDi.com
Put your pens down @coldclimate CANDDi.com
There once was a man... @coldclimate CANDDi.com
And then there was a document... @coldclimate CANDDi.com
Which became a wiki... @coldclimate CANDDi.com
Which finally because a script @coldclimate CANDDi.com
Which mostly worked... @coldclimate CANDDi.com
And then the madness had to stop @coldclimate CANDDi.com
You wouldn’t treat code like this (hopefully) @coldclimate CANDDi.com
Man => Document => Wiki => Script => Images @coldclimate
CANDDi.com
Encoding Version controlling (automating) @coldclimate CANDDi.com
Man => Document Removing the bus factor “The man we
can’t fire” @coldclimate CANDDi.com
Document => Wiki The fucker *might* stay up to date
@coldclimate CANDDi.com
Wiki => Script Because script in documentation is stupid @coldclimate
CANDDi.com
@coldclimate CANDDi.com
Why are you not talking about chef, puppet, ansible etc?
@coldclimate CANDDi.com
http://widgetsandshit.com/teddziuba/2010/10/taco-bell-programming.html @coldclimate CANDDi.com
Build once or build twice? @coldclimate CANDDi.com
Build once Raw OS Base Instance Script Working Instance @coldclimate
CANDDi.com
Kick-off instance Install packages Configure them Install your software Hope
it all works @coldclimate CANDDi.com
Build Twice Raw OS Base Instance Script “Base Box” Make
AMI “Base Box” “Instance Box” Script Base AMI @coldclimate CANDDi.com
Build once or build twice? @coldclimate CANDDi.com
Kick-off instance Install packages -------------------------------------------- Configure them Install your software
@coldclimate CANDDi.com
Kick-off instance Install packages -------------------------------------------- Configure them Install your software
Changes rarely Changes frequently
Kick-off instance Install packages -------------------------------------------- Configure them Install your software
AMI Instance
Stability @coldclimate CANDDi.com
Speed @coldclimate CANDDi.com
The game: always runs, no manual fixes @coldclimate CANDDi.com
A script to built an AMI https://gist.github.com/coldclimate/5ff56c96dac116f3234e @coldclimate CANDDi.com
ec2-run-instances --region 'eu-west-1' -g TEMP -k TEMP -f install.sh -t
t1.micro ami-ce7b6fba @coldclimate CANDDi.com
install.sh limited size (16kb) runs as root cock to debug
@coldclimate CANDDi.com
/var/log/cloud-init.log @coldclimate CANDDi.com
set -ex @coldclimate CANDDi.com
Add any sources Update the APT repository Install core packages
@coldclimate CANDDi.com
Add any sources @coldclimate CANDDi.com
echo "deb http://archive.canonical.com/ precise partner" | sudo tee -a /etc/apt/sources.list
@coldclimate CANDDi.com
python-setuptools add-apt-repository -y ppa:ondrej/php5 @coldclimate CANDDi.com
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist
10gen' | sudo tee /etc/apt/sources.list.d/10gen.list @coldclimate CANDDi.com
Update the APT repository @coldclimate CANDDi.com
apt-get update @coldclimate CANDDi.com
Install core packages @coldclimate CANDDi.com
apt-get -y install zip unzip xmlstarlet sysstat iftop ntp sysvbanner
build- essential python-setuptools nginx nodejs @coldclimate CANDDi.com
easy_install -U boto @coldclimate CANDDi.com
wget https://github.com/nicolasff/phpredis/archive/2.2.4.zip -P /tmp/ mkdir -p /opt/code unzip /tmp/2.2.4.zip -d
/opt/code/ cd /opt/code/phpredis-2.2.4 phpize ./configure make make install @coldclimate CANDDi.com
banner “*** DONE BABY ***” @coldclimate CANDDi.com
ec2-create-image -n<ami-name> instance_id @coldclimate CANDDi.com
Making running instance @coldclimate CANDDi.com
ec2-run-instances --region 'eu-west-1' -g sg-bb18b66c -k LIVE-PEM-KEY -p Instance_Profile -f
install.sh -t m1.small --availability-zone eu-west-1a --disable-api-termination ami-XXXXXX @coldclimate CANDDi.com
Roles http://docs.aws.amazon.com/cli/latest/reference/iam/create-role.html Instance Profiles http://docs.aws.amazon.com/cli/latest/reference/iam/create-instance-profile.html Adding a Role to an
Instance Profile http://docs.aws.amazon.com/cli/latest/reference/iam/add-role-to-instance-profile.html @coldclimate CANDDi.com
Download from S3 Setup directories Setup config Install code Start
it up Register it @coldclimate CANDDi.com
Download from S3 python <<PY import boto import sys from
boto.s3.key import Key def get_wonka(bucket_name, file_name, destination_file): conn = boto.connect_s3() bucket = conn.get_bucket(bucket_name) k = Key(bucket) k.name = file_name destination = "/tmp/%s" % (destination_file) k.get_contents_to_filename(destination) get_wonka("BUCKET","SOURCEFILE","DESTINATION") PY @coldclimate CANDDi.com
Setup directories Your script is running as root so remember
to chown @coldclimate CANDDi.com
Setup config Copy it from the download into place Restart
the service @coldclimate CANDDi.com
Install code https://github.com/jordansissel/fpm @coldclimate CANDDi.com
Start it up Supervisord Ubuntu service Avoid own scripts @coldclimate
CANDDi.com
Register it @coldclimate CANDDi.com
Monitoring (zabbix) @coldclimate CANDDi.com
Load Balancer (ec2 call) @coldclimate CANDDi.com
Logging (papertrail) @coldclimate CANDDi.com
DNS (R53 call) @coldclimate CANDDi.com
And it works! @coldclimate CANDDi.com
@coldclimate CANDDi.com
Need to change the code or config? @coldclimate CANDDi.com
JFDI and roll a fresh one @coldclimate CANDDi.com
You need to change the base AMI @coldclimate CANDDi.com
It’s simple, it just doesn’t feel it @coldclimate CANDDi.com
Update the scripts until you can “launch clean” @coldclimate CANDDi.com
Lastly @coldclimate CANDDi.com
@coldclimate CANDDi.com
speakerdeck. com/coldclimate/scripting-creating- aws-based-servers @coldclimate canddi.com/blog @coldclimate CANDDi.com