Class: AWS::AutoScaling::LaunchConfigurationCollection

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

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

Instance Method Details

#[](name) ⇒ LaunchConfiguration

Parameters:

  • name (String)

    The name of a launch configuraiton.

Returns:



101
102
103
# File 'lib/aws/auto_scaling/launch_configuration_collection.rb', line 101

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.

  • :iam_instance_profile (String)
  • :spot_price (String)

Returns:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/aws/auto_scaling/launch_configuration_collection.rb', line 67

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[:instance_monitoring] = instance_monitoring_opt(options) if
    options.key?(:detailed_instance_monitoring)
  client_opts[:key_name] = key_name_opt(options) if options[:key_pair]
  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]

  [
    :iam_instance_profile,
    :spot_price,
    :kernel_id,
    :ramdisk_id,
    :block_device_mappings,
  ].each do |opt|
    client_opts[opt] = options[opt] if options.key?(opt)
  end

  client.create_launch_configuration(client_opts)

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

end