Class: Aerosol::LaunchTemplate
- Inherits:
-
Object
- Object
- Aerosol::LaunchTemplate
show all
- Includes:
- AWSModel, Dockly::Util::Logger::Mixin
- Defined in:
- lib/aerosol/launch_template.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from AWSModel
#create, #default_identifier, #destroy, #exists?, included, #initialize, #namespaced_name
Class Method Details
.request_all ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/aerosol/launch_template.rb', line 65
def self.request_all
next_token = nil
lts = []
begin
new_lts = request_all_for_token(next_token)
lts.concat(new_lts.launch_templates)
next_token = new_lts.next_token
end until next_token.nil?
lts
end
|
.request_all_for_token(next_token) ⇒ Object
60
61
62
63
|
# File 'lib/aerosol/launch_template.rb', line 60
def self.request_all_for_token(next_token)
options = next_token.nil? ? {} : { next_token: next_token }
Aerosol::AWS.compute.describe_launch_templates(options)
end
|
Instance Method Details
#all_instances ⇒ Object
53
54
55
56
57
58
|
# File 'lib/aerosol/launch_template.rb', line 53
def all_instances
Aerosol::Instance.all.select { |instance|
!instance.launch_template.nil? &&
(instance.launch_template.launch_template_name == launch_template_name)
}.each(&:description)
end
|
#corrected_user_data ⇒ Object
96
97
98
99
100
|
# File 'lib/aerosol/launch_template.rb', line 96
def corrected_user_data
realized_user_data = user_data.is_a?(Proc) ? user_data.call : user_data
Base64.encode64(Aerosol::Util.strip_heredoc(realized_user_data || ''))
end
|
#create! ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/aerosol/launch_template.rb', line 29
def create!
ensure_present! :image_id, :instance_type
info "creating launch template"
conn.create_launch_template(
launch_template_name: launch_template_name,
launch_template_data: {
image_id: image_id,
instance_type: instance_type,
monitoring: {
enabled: true
},
}.merge(create_options)
)
debug self.inspect
end
|
#destroy! ⇒ Object
47
48
49
50
51
|
# File 'lib/aerosol/launch_template.rb', line 47
def destroy!
info self.to_s
raise StandardError.new('No launch_template_name found') unless launch_template_name
conn.delete_launch_template(launch_template_name: launch_template_name)
end
|
#launch_template_name(arg = nil) ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/aerosol/launch_template.rb', line 16
def launch_template_name(arg = nil)
if arg
raise "You cannot set the launch_template_name directly" unless from_aws
@launch_template_name = arg
else
@launch_template_name || default_identifier
end
end
|
#security_group(group) ⇒ Object
25
26
27
|
# File 'lib/aerosol/launch_template.rb', line 25
def security_group(group)
security_groups << group
end
|
#to_s ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/aerosol/launch_template.rb', line 77
def to_s
%{Aerosol::LaunchTemplate { \
"launch_template_name" => "#{launch_template_name}", \
"launch_template_id" => "#{launch_template_id}", \
"latest_version_number" => "#{latest_version_number}", \
"image_id" => "#{image_id}", \
"instance_type" => "#{instance_type}", \
"security_group_ids" => #{security_groups.to_s}, \
"user_data" => "#{user_data}", \
"iam_instance_profile" => "#{iam_instance_profile}", \
"kernel_id" => "#{kernel_id}", \
"key_name" => "#{key_name}", \
"spot_price" => "#{spot_price}", \
"created_time" => "#{created_time}", \
"block_device_mappings" => #{block_device_mappings}", \
"ebs_optimized" => #{ebs_optimized} \
}}
end
|