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
210
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
100
Quick and dirty load testing with Vegeta
coldclimate
3
3.9k
Continuously deploying https served statically compiled sites to S3 with canonical domains
coldclimate
0
58
Scaling CANDDi
coldclimate
0
190
refactoring
coldclimate
1
120
Other Decks in Technology
See All in Technology
エンジニア候補者向け資料2024.03.28.pdf
macloud
0
2.9k
事業部を超えた 開発生産性向上に挑戦する
kentakozuka
5
930
関数型DDDの理論と実践:「決定を遅らせる」を先につくり、 ビジネスの機動力と価値をあげる
knih
2
150
データ化エンジニアとしての1年を振り返る
sansantech
PRO
3
250
学生としてRSGT2024に参加して得られた学び / Lessons learned from participating in RSGT2024 as a student
fujiemon
0
110
複数の LLM モデルを扱う上で直面した辛みまとめ
kazuyaseki
1
210
GraphQLに入門してみた
chiroruxx
2
100
Azureコストは水道代/The_47th_Tokyo_Jazug
aeonpeople
3
350
生成AIサービスPanorama AIご説明資料
sdt
0
300
Ask-LLM論文紹介: How to Train Data-Efficient LLMs
s_ota
0
110
ハイパフォーマンスな組織をつくるための開発生産性の考え方 / developer-productivity-high-performer-link-and-motivation
lmi
3
220
PG-Stromの性能評価レポート~ Star Schema Benchmark を例に~ / pgstrom_ssb_report_2024
sakaik
0
100
Featured
See All Featured
It's Worth the Effort
3n
180
27k
Building Your Own Lightsaber
phodgson
97
5.6k
Build The Right Thing And Hit Your Dates
maggiecrowley
23
1.9k
Building an army of robots
kneath
300
41k
Thoughts on Productivity
jonyablonski
57
3.8k
A designer walks into a library…
pauljervisheath
199
23k
The Cost Of JavaScript in 2023
addyosmani
13
3.7k
The Power of CSS Pseudo Elements
geoffreycrofte
58
4.9k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
57
14k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
67
38k
jQuery: Nuts, Bolts and Bling
dougneiner
57
7.1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
111
35k
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