aws-ami 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +31 -1
- data/bin/aws-ami +5 -0
- data/lib/aws_ami/ami.rb +9 -1
- metadata +1 -1
data/README
CHANGED
@@ -1 +1,31 @@
|
|
1
|
-
= AWS AMI
|
1
|
+
= AWS AMI
|
2
|
+
|
3
|
+
A tool for creating AWS AMI from a base AMI and an install packages script
|
4
|
+
|
5
|
+
Example:
|
6
|
+
|
7
|
+
After installed aws-ami.
|
8
|
+
Setup aws access env variables:
|
9
|
+
|
10
|
+
export AWS_ACCESS_KEY_ID='your aws access key id'
|
11
|
+
export AWS_SECRET_ACCESS_KEY='your aws secret access key'
|
12
|
+
|
13
|
+
Pick base ami and setup base_ami_yml file (As we use user-data to inject install_packages_script to install packages, the base AMI need support user-data.):
|
14
|
+
|
15
|
+
us-west-1: ami-102923
|
16
|
+
eu-west-1: ami-232340
|
17
|
+
|
18
|
+
write a script to install packages on the AMI (install_packages_script.sh example):
|
19
|
+
|
20
|
+
#!/bin/sh -eu
|
21
|
+
sudo apt-get install rubygems
|
22
|
+
....
|
23
|
+
|
24
|
+
Then you should be ready to run the following command to create a new AMI:
|
25
|
+
|
26
|
+
aws-ami -n ami_name -r us-west-1 -f install_packages_script.sh -k ssh_key_name -b base_ami_yml_path
|
27
|
+
|
28
|
+
|
29
|
+
All options:
|
30
|
+
|
31
|
+
aws-ami -h
|
data/bin/aws-ami
CHANGED
@@ -46,6 +46,11 @@ OptionParser.new do |opts|
|
|
46
46
|
opts.on('--dry', "output all options values") do
|
47
47
|
options[:dry] = true
|
48
48
|
end
|
49
|
+
|
50
|
+
opts.on('--test', 'launch EC2 instance and install packages, but leave everything there for test') do
|
51
|
+
options[:test] = true
|
52
|
+
end
|
53
|
+
|
49
54
|
end.parse!
|
50
55
|
|
51
56
|
if options[:dry]
|
data/lib/aws_ami/ami.rb
CHANGED
@@ -9,6 +9,7 @@ module AWS
|
|
9
9
|
@assume_yes = options[:assume_yes]
|
10
10
|
@region = options[:region]
|
11
11
|
@publish_to_account = options[:publish_to_account]
|
12
|
+
@test = options[:test]
|
12
13
|
end
|
13
14
|
|
14
15
|
# name: new AMI name, for example: mingle-saas-base
|
@@ -26,7 +27,14 @@ module AWS
|
|
26
27
|
wait_until_created(stack)
|
27
28
|
begin
|
28
29
|
instance_id = stack.resources['EC2Instance'].physical_resource_id
|
29
|
-
|
30
|
+
if @test
|
31
|
+
unless gets.strip == 'y'
|
32
|
+
logger.info "delete stack and stop"
|
33
|
+
stack.delete
|
34
|
+
return
|
35
|
+
end
|
36
|
+
logger.info "continue to create image"
|
37
|
+
end
|
30
38
|
logger.info "creating image"
|
31
39
|
image = ec2.instances[instance_id].create_image(name, :description => "Created at #{Time.now}")
|
32
40
|
sleep 2 until image.exists?
|