Class: AWS::AutoScaling::LaunchConfigurationCollection

Inherits:
Object
  • Object
show all
Includes:
Core::Collection::Limitable
Defined in:
lib/aws/auto_scaling/launch_configuration_collection.rb

Instance Attribute Summary

Attributes included from Core::Model

#config

Instance Method Summary collapse

Methods included from Core::Collection::Limitable

#each_batch

Methods included from Core::Collection

#each, #each_batch, #enum, #first, #in_groups_of, #page

Methods included from Core::Model

#client, #config_prefix, #initialize, #inspect

Instance Method Details

#[](name) ⇒ LaunchConfiguration

Parameters:

  • name (String)

    The name of a launch configuraiton.

Returns:



91
92
93
# File 'lib/aws/auto_scaling/launch_configuration_collection.rb', line 91

def [] name
  LaunchConfiguration.new(name, :config => config)
end

#create(name, image, instance_type, options = {}) ⇒ LaunchConfiguration

Creates an Auto Scaling launch configuration.

auto_scaling.launch_configurations.create('name', 'ami-12345', 'm1.small')

Parameters:

  • name (String)

    The name of the launch configuration to create.

  • image (EC2::Image, String)

    An EC2::Image or image id string.

  • instance_type (String)

    The type of instance (e.g. ‘t1.micro’, ‘m1.small’, ‘m2.4xlarge’, etc).

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :block_device_mappings (Array<Hash>)
  • :detailed_instance_monitoring (Boolean) — default: true

    When enabled, CloudWatch will generate metrics every minute and your account will be charged a fee. When you disable detailed monitoring, by specifying False, Cloudwatch will generate metrics every 5 minutes.

  • :kernel_id (String)

    The ID of the kernel to launch the instances with.

  • :key_pair (KeyPair, String)

    The keypair to launch instances with. This may be an EC2::KeyPair object or or key pair name string.

  • :ramdisk_id (String)

    The ID of the ramdisk to launch the instances with.

  • :security_groups (Array<EC2::SecurityGroup>, Array<String>)

    The list of security groups to associate with the instances. This may be an array of EC2::SecurityGroup objects, security group names or security group ids.

  • :user_data (String)

    The user data available to the launched Amazon EC2 instances.

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/aws/auto_scaling/launch_configuration_collection.rb', line 63

def create name, image, instance_type, options = {}
  
  client_opts = {}
  client_opts[:launch_configuration_name] = name
  client_opts[:image_id] = image_id_opt(image)
  client_opts[:instance_type] = instance_type
  client_opts[:block_device_mappings] = options[:block_device_mappings] if
    options.key?(:block_device_mappings)
  client_opts[:instance_monitoring] = instance_monitoring_opt(options) if
    options.key?(:detailed_instance_monitoring)
  client_opts[:kernel_id] = options[:kernel_id] if options[:kernel_id]
  client_opts[:key_name] = key_name_opt(options) if options[:key_pair]
  client_opts[:ramdisk_id] = options[:ramdisk_id] if options[:ramdisk_id]
  client_opts[:security_groups] = security_groups_opt(options) if
    options.key?(:security_groups)
  client_opts[:user_data] = user_data_opt(options) if options[:user_data]

  client.create_launch_configuration(client_opts)

  LaunchConfiguration.new(name,
    :image_id => client_opts[:image_id],
    :instance_type => client_opts[:instance_type],
    :config => config)

end