class Awful::LaunchConfig
Public Instance Methods
clean(name, num = 1)
click to toggle source
# File lib/awful/launch_config.rb, line 32 def clean(name, num = 1) autoscaling.describe_launch_configurations.map(&:launch_configurations).flatten.select do |lc| lc.launch_configuration_name.match(name) end.sort_by(&:created_time).first(num.to_i).map(&:launch_configuration_name).tap do |names| puts names if yes? 'delete these launch configs?', :yellow names.each do |n| autoscaling.delete_launch_configuration(launch_configuration_name: n) end end end end
create(file = nil)
click to toggle source
# File lib/awful/launch_config.rb, line 73 def create(file = nil) opt = load_cfg(options, file) whitelist = %i[launch_configuration_name image_id key_name security_groups classic_link_vpc_id classic_link_vpc_security_groups user_data instance_id instance_type kernel_id ramdisk_id block_device_mappings instance_monitoring spot_price iam_instance_profile ebs_optimized associate_public_ip_address placement_tenancy] if options[:timestamp] opt[:launch_configuration_name] += "-#{Time.now.utc.strftime('%Y%m%d%H%M%S')}" end opt[:user_data] = Base64.encode64(opt[:user_data]) # encode user data opt = remove_empty_strings(opt) opt = only_keys_matching(opt, whitelist) autoscaling.create_launch_configuration(opt) opt[:launch_configuration_name].tap do |name| puts name end end
delete(name)
click to toggle source
# File lib/awful/launch_config.rb, line 27 def delete(name) autoscaling.delete_launch_configuration(launch_configuration_name: name) end
dump(*names)
click to toggle source
# File lib/awful/launch_config.rb, line 47 def dump(*names) paginate(:launch_configurations) do |token| autoscaling.describe_launch_configurations(launch_configuration_names: names, next_token: token) end.tap do |lcs| lcs.select! { |lc| lc.launch_configuration_name.match(options[:match]) } if options[:match] end.output do |lcs| lcs.each do |lc| lc[:user_data] = Base64.decode64(lc[:user_data]) puts YAML.dump(stringify_keys(lc.to_hash)) end end end
latest(name)
click to toggle source
# File lib/awful/launch_config.rb, line 61 def latest(name) autoscaling.describe_launch_configurations.map(&:launch_configurations).flatten.select do |lc| lc.launch_configuration_name.match(/^#{name}/) end.sort_by(&:created_time).last.launch_configuration_name.tap do |latest| puts latest end end
ls(*names)
click to toggle source
# File lib/awful/launch_config.rb, line 10 def ls(*names) paginate(:launch_configurations) do |token| autoscaling.describe_launch_configurations(launch_configuration_names: names, next_token: token) end.tap do |lcs| lcs.select! { |lc| lc.launch_configuration_name.match(options[:match]) } if options[:match] end.output do |lcs| if options[:long] print_table lcs.map { |lc| [lc.launch_configuration_name, lc.image_id, lc.instance_type, lc.created_time] } else puts lcs.map(&:launch_configuration_name) end end end