aws-ec2 0.3.0 → 0.4.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +84 -52
- data/README.md +3 -4
- data/aws-ec2.gemspec +3 -0
- data/lib/aws-ec2.rb +7 -4
- data/lib/aws_ec2/ami.rb +7 -8
- data/lib/aws_ec2/cli.rb +12 -10
- data/lib/aws_ec2/command.rb +13 -0
- data/lib/aws_ec2/compile_scripts.rb +30 -0
- data/lib/aws_ec2/core.rb +4 -1
- data/lib/aws_ec2/create.rb +14 -84
- data/lib/aws_ec2/create/params.rb +157 -0
- data/lib/aws_ec2/dotenv.rb +30 -0
- data/lib/aws_ec2/help/ami.md +11 -0
- data/lib/aws_ec2/help/create.md +3 -3
- data/lib/aws_ec2/help/user_data.md +4 -4
- data/lib/aws_ec2/hook.rb +32 -0
- data/lib/aws_ec2/script.rb +26 -0
- data/lib/aws_ec2/scripts/ami_creation.sh +24 -16
- data/lib/aws_ec2/scripts/auto_terminate.sh +95 -0
- data/lib/aws_ec2/template_helper.rb +47 -12
- data/lib/aws_ec2/template_helper/ami_helper.rb +23 -0
- data/lib/aws_ec2/template_helper/partial_helper.rb +71 -0
- data/lib/aws_ec2/version.rb +1 -1
- data/spec/fixtures/demo_project/config/test.yml +9 -0
- data/spec/fixtures/demo_project/profiles/default.yml +33 -0
- data/spec/lib/cli_spec.rb +9 -4
- data/spec/spec_helper.rb +4 -3
- metadata +57 -8
- data/example/profiles/spot/default.yml +0 -14
- data/example/profiles/spot/dev.yml +0 -15
- data/lib/aws_ec2/help/spot.md +0 -3
- data/lib/aws_ec2/spot.rb +0 -81
- data/lib/aws_ec2/user_data.rb +0 -17
- data/lib/aws_ec2/util.rb +0 -64
data/lib/aws_ec2/user_data.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'active_support/core_ext/hash'
|
3
|
-
|
4
|
-
module AwsEc2
|
5
|
-
class UserData
|
6
|
-
include TemplateHelper
|
7
|
-
include Util
|
8
|
-
|
9
|
-
def initialize(options)
|
10
|
-
@options = options
|
11
|
-
end
|
12
|
-
|
13
|
-
def run
|
14
|
-
puts user_data(@options[:name], false)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
data/lib/aws_ec2/util.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
module AwsEc2
|
2
|
-
module Util
|
3
|
-
include TemplateHelper
|
4
|
-
|
5
|
-
def pretty_display(data)
|
6
|
-
data = data.deep_stringify_keys
|
7
|
-
|
8
|
-
message = "base64-encoded: use aws-ec2 userdata command to view"
|
9
|
-
# TODO: generalize this
|
10
|
-
data["user_data"] = message if data["user_data"]
|
11
|
-
data["spot_fleet_request_config"]["launch_specifications"].each do |spec|
|
12
|
-
spec["user_data"] = message if spec["user_data"]
|
13
|
-
end if data["spot_fleet_request_config"] && data["spot_fleet_request_config"]["launch_specifications"]
|
14
|
-
|
15
|
-
puts YAML.dump(data)
|
16
|
-
end
|
17
|
-
|
18
|
-
def load_profiles(profile_name)
|
19
|
-
return @profile_params if @profile_params
|
20
|
-
|
21
|
-
profile_file = "#{root}/profiles/#{profile_name}.yml"
|
22
|
-
base_path = File.dirname(profile_file)
|
23
|
-
default_file = "#{base_path}/default.yml"
|
24
|
-
|
25
|
-
params_exit_check!(profile_file, default_file)
|
26
|
-
|
27
|
-
params = File.exist?(profile_file) ?
|
28
|
-
load_profile(profile_file) :
|
29
|
-
load_profile(default_file)
|
30
|
-
@profile_params = params
|
31
|
-
end
|
32
|
-
|
33
|
-
def params_exit_check!(profile_file, default_file)
|
34
|
-
return if File.exist?(profile_file) or File.exist?(default_file)
|
35
|
-
|
36
|
-
puts "Unable to find a #{profile_file} or #{default_file} profile file."
|
37
|
-
puts "Please double check."
|
38
|
-
exit # EXIT HERE
|
39
|
-
end
|
40
|
-
|
41
|
-
def load_profile(file)
|
42
|
-
return {} unless File.exist?(file)
|
43
|
-
|
44
|
-
puts "Using profile: #{file}"
|
45
|
-
data = YAML.load(erb_result(file))
|
46
|
-
data ? data : {} # in case the file is empty
|
47
|
-
data.has_key?("run_instances") ? data["run_instances"] : data
|
48
|
-
end
|
49
|
-
|
50
|
-
def profile_name
|
51
|
-
# allow user to specify the path also
|
52
|
-
if @options[:profile] && File.exist?(@options[:profile])
|
53
|
-
profile = File.basename(@options[:profile], '.yml')
|
54
|
-
end
|
55
|
-
|
56
|
-
# conventional profile is the name of the ec2 instance
|
57
|
-
profile || @options[:profile] || @options[:name]
|
58
|
-
end
|
59
|
-
|
60
|
-
def root
|
61
|
-
ENV['AWS_EC2_ROOT'] || '.'
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|