Skip to content

Instantly share code, notes, and snippets.

@dysinger
Last active October 6, 2015 11:43
Show Gist options
  • Save dysinger/69deb4bc6de818d06759 to your computer and use it in GitHub Desktop.
Save dysinger/69deb4bc6de818d06759 to your computer and use it in GitHub Desktop.
Vagrant AWS config for Haskell projects
# -*- mode: ruby -*-
# vi: set ft=ruby :
# install:
# `vagrant plugin install vagrant-aws`
# `vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box`
# config:
# `export AWS_ACCESS_KEY_ID='...'`
# `export AWS_SECRET_ACCESS_KEY='...'`
# `export AWS_REGION='us-west-2'`
# launch:
# `vagrant up --provider=aws`
# reprovision (rsyncs project dir too):
# `vagrant provision`
# destroy:
# `vagrant destroy`
Vagrant.configure('2') do |config|
config.vm.provider :aws do |aws, override|
aws.access_key_id = ACCESS
aws.secret_access_key = SECRET
aws.region = REGION
aws.instance_type = INSTANCE
aws.security_groups = GROUPS
aws.keypair_name = KEYPAIR
aws.user_data = USERDATA
aws.region_config 'ap-northeast-1', ami: 'ami-a929c5a9' # http://cloud-images.ubuntu.com
aws.region_config 'ap-southeast-1', ami: 'ami-5cf6c10e'
aws.region_config 'ap-southeast-2', ami: 'ami-fd3342c7'
aws.region_config 'cn-north-1', ami: 'ami-2204961b'
aws.region_config 'eu-central-1', ami: 'ami-16e8da0b'
aws.region_config 'eu-west-1', ami: 'ami-93c756e4'
aws.region_config 'sa-east-1', ami: 'ami-9dc87180'
aws.region_config 'us-east-1', ami: 'ami-12fea27a'
aws.region_config 'us-gov-west-1', ami: 'ami-b3422390'
aws.region_config 'us-west-1', ami: 'ami-27ac4863'
aws.region_config 'us-west-2', ami: 'ami-a7785897'
override.ssh.private_key_path = "~/.ssh/#{KEYPAIR}-#{REGION}.pem"
override.ssh.username = 'ubuntu'
override.vm.box = 'dummy'
override.vm.synced_folder(
'.',
"/home/ubuntu/src/#{File.basename(File.expand_path('..', __FILE__))}/",
type: 'rsync',
owner: 'ubuntu',
create: true,
rsync__exclude: [ '.git/', 'dist/', '.cabal-sandbox/' ]
)
end
end
ACCESS = ENV['AWS_ACCESS_KEY_ID'] ||
begin
throw 'REQUIRED: AWS_ACCESS_KEY_ID ENV VARIABLE'
end
SECRET = ENV['AWS_SECRET_ACCESS_KEY'] ||
begin
throw 'REQUIRED: AWS_SECRET_ACCESS_KEY ENV VARIABLE'
end
REGION = ENV['AWS_REGION'] || 'us-east-1'
KEYPAIR = ENV['AWS_KEYPAIR'] || 'default'
INSTANCE = ENV['AWS_INSTANCE'] || 'm3.medium'
GROUPS = begin
require 'CSV'
(ENV['AWS_GROUPS'] || 'default').strip.parse_csv
end
USERDATA = <<EOF
#!/bin/bash
apt-get update
apt-get upgrade -y
apt-get install -y python-software-properties
add-apt-repository -y ppa:hvr/ghc
apt-get update
apt-get install -y ghc-7.8.4 cabal-install-1.20 \
build-essential libffi-dev zlib1g-dev git tig tmux htop itop
apt-get install -y emacs24-nox || apt-get install -y emacs23-nox
echo 'PATH=/opt/ghc/7.8.4/bin:$PATH' | tee /etc/profile.d/ghc.sh
echo 'PATH=/opt/cabal/1.20/bin:$PATH' | tee /etc/profile.d/cabal.sh
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment