-
-
Save mahmoudimus/0c829c4e1f6ccb49e19e to your computer and use it in GitHub Desktop.
setup vagrant spot instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone [email protected]:KariusDx/vagrant-aws.git | |
cd vagrant-aws | |
gem build vagrant-aws.gemspec | |
vagrant install plugin vagrant-aws-0.6.0.spot.gem | |
# use the attached Vagrantfile and run vagrant aws --provider=aws |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REGION = "us-west-1" | |
USERNAME = "mahmoud" | |
UBUNTU_14_04 = "ami-df6a8b9b" | |
Vagrant.configure("2") do |config| | |
config.vm.box = "dummy" | |
config.vm.provider :aws do |aws, override| | |
aws.access_key_id = ENV['AWS_ACCESS_KEY_ID'] | |
aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY'] | |
# http://aws.amazon.com/ec2/pricing/#spot | |
aws.instance_type = "m4.large" | |
aws.keypair_name = "mahmoud" | |
aws.ami = UBUNTU_14_04 | |
aws.region = REGION | |
aws.subnet_id = "subnet-e4a41a81" | |
aws.associate_public_ip = true | |
aws.tags = { | |
'Name' => 'rdevbox', | |
} | |
aws.security_groups = [ | |
"sg-a99d12cc" | |
] | |
aws.region_config REGION do |region| | |
region.spot_instance = true | |
region.spot_max_price = "0.019" | |
end | |
# aws.block_device_mapping = [ | |
# { | |
# 'DeviceName' => "/dev/sdl", | |
# 'VirtualName' => "mysql_data", | |
# 'Ebs.VolumeSize' => 100, | |
# 'Ebs.DeleteOnTermination' => true, | |
# 'Ebs.VolumeType' => 'io1', | |
# 'Ebs.Iops' => 1000 | |
# } | |
# ] | |
aws.user_data = <<EOF | |
#!/bin/bash | |
useradd -m -d /home/#{USERNAME} -s /bin/bash #{USERNAME} | |
usermod -a -G admin #{USERNAME} | |
echo '#{USERNAME}:#{USERNAME}' | chpasswd | |
cp -pR ~ubuntu/.ssh ~#{USERNAME} | |
chown -R #{USERNAME}: ~#{USERNAME}/.ssh/ | |
EOF | |
override.ssh.username = USERNAME | |
override.ssh.pty = true # http://stackoverflow.com/a/17436026/133514 | |
override.ssh.private_key_path = "#{File.expand_path('~')}/.ssh/id_rsa" | |
end | |
config.vm.synced_folder ".", "/vagrant", disabled: true | |
config.vm.synced_folder '.', "/home/#{USERNAME}/code" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment