You are viewing documentation for version 3 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: Aws::AutoScaling::LaunchConfiguration

Inherits:
Object
  • Object
show all
Defined in:
gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb

Defined Under Namespace

Classes: Collection

Actions collapse

Read-Only Attributes collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ LaunchConfiguration #initialize(options = {}) ⇒ LaunchConfiguration

Returns a new instance of LaunchConfiguration

Overloads:



19
20
21
22
23
24
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 19

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @name = extract_name(args, options)
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
end

Instance Method Details

#associate_public_ip_addressBoolean

For Auto Scaling groups that are running in a VPC, specifies whether to assign a public IP address to the group's instances.

For more information, see Launching Auto Scaling Instances in a VPC in the Amazon EC2 Auto Scaling User Guide.

Returns:

  • (Boolean)


240
241
242
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 240

def associate_public_ip_address
  data[:associate_public_ip_address]
end

#block_device_mappingsArray<Types::BlockDeviceMapping>

A block device mapping, which specifies the block devices for the instance.

For more information, see Block Device Mapping in the Amazon EC2 User Guide for Linux Instances.

Returns:



162
163
164
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 162

def block_device_mappings
  data[:block_device_mappings]
end

The ID of a ClassicLink-enabled VPC to link your EC2-Classic instances to.

For more information, see ClassicLink in the Amazon EC2 User Guide for Linux Instances and Linking EC2-Classic Instances to a VPC in the Amazon EC2 Auto Scaling User Guide.

Returns:

  • (String)


93
94
95
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 93

def classic_link_vpc_id
  data[:classic_link_vpc_id]
end

The IDs of one or more security groups for the VPC specified in ClassicLinkVPCId.

For more information, see ClassicLink in the Amazon EC2 User Guide for Linux Instances and Linking EC2-Classic Instances to a VPC in the Amazon EC2 Auto Scaling User Guide.

Returns:

  • (Array<String>)


109
110
111
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 109

def classic_link_vpc_security_groups
  data[:classic_link_vpc_security_groups]
end

#clientClient

Returns:



262
263
264
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 262

def client
  @client
end

#created_timeTime

The creation date and time for the launch configuration.

Returns:

  • (Time)


212
213
214
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 212

def created_time
  data[:created_time]
end

#dataTypes::LaunchConfiguration



282
283
284
285
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 282

def data
  load unless @data
  @data
end

#data_loaded?Boolean

Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



290
291
292
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 290

def data_loaded?
  !!@data
end

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


launch_configuration.delete()

Parameters:

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

    ({})

Returns:

  • (EmptyStructure)


396
397
398
399
400
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 396

def delete(options = {})
  options = options.merge(launch_configuration_name: @name)
  resp = @client.delete_launch_configuration(options)
  resp.data
end

#ebs_optimizedBoolean

Specifies whether the launch configuration is optimized for EBS I/O (true) or not (false).

For more information, see Amazon EBS-Optimized Instances in the Amazon EC2 User Guide for Linux Instances.

Returns:

  • (Boolean)


226
227
228
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 226

def ebs_optimized
  data[:ebs_optimized]
end

#iam_instance_profileString

The name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance. The instance profile contains the IAM role.

For more information, see IAM Role for Applications That Run on Amazon EC2 Instances in the Amazon EC2 Auto Scaling User Guide.

Returns:

  • (String)


206
207
208
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 206

def iam_instance_profile
  data[:iam_instance_profile]
end

#image_idString

The ID of the Amazon Machine Image (AMI) to use to launch your EC2 instances.

For more information, see Finding an AMI in the Amazon EC2 User Guide for Linux Instances.

Returns:

  • (String)


50
51
52
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 50

def image_id
  data[:image_id]
end

#instance_monitoringTypes::InstanceMonitoring

Controls whether instances in this group are launched with detailed (true) or basic (false) monitoring.

For more information, see Configure Monitoring for Auto Scaling Instances in the Amazon EC2 Auto Scaling User Guide.



176
177
178
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 176

def instance_monitoring
  data[:instance_monitoring]
end

#instance_typeString

The instance type for the instances.

For information about available instance types, see Available Instance Types in the Amazon EC2 User Guide for Linux Instances.

Returns:

  • (String)


136
137
138
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 136

def instance_type
  data[:instance_type]
end

#kernel_idString

The ID of the kernel associated with the AMI.

Returns:

  • (String)


142
143
144
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 142

def kernel_id
  data[:kernel_id]
end

#key_nameString

The name of the key pair.

For more information, see Amazon EC2 Key Pairs in the Amazon EC2 User Guide for Linux Instances.

Returns:

  • (String)


63
64
65
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 63

def key_name
  data[:key_name]
end

#launch_configuration_arnString

The Amazon Resource Name (ARN) of the launch configuration.

Returns:

  • (String)


36
37
38
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 36

def launch_configuration_arn
  data[:launch_configuration_arn]
end

#loadself Also known as: reload

Loads, or reloads #data for the current Aws::AutoScaling::LaunchConfiguration. Returns self making it possible to chain methods.

launch_configuration.reload.data

Returns:

  • (self)


272
273
274
275
276
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 272

def load
  resp = @client.describe_launch_configurations(launch_configuration_names: [@name])
  @data = resp.launch_configurations[0]
  self
end

#nameString Also known as: launch_configuration_name

Returns:

  • (String)


29
30
31
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 29

def name
  @name
end

#placement_tenancyString

The tenancy of the instance, either default or dedicated. An instance with dedicated tenancy runs on isolated, single-tenant hardware and can only be launched into a VPC.

For more information, see Instance Placement Tenancy in the Amazon EC2 Auto Scaling User Guide.

Returns:

  • (String)


255
256
257
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 255

def placement_tenancy
  data[:placement_tenancy]
end

#ramdisk_idString

The ID of the RAM disk associated with the AMI.

Returns:

  • (String)


148
149
150
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 148

def ramdisk_id
  data[:ramdisk_id]
end

#security_groupsArray<String>

A list that contains the security groups to assign to the instances in the Auto Scaling group.

For more information, see Security Groups for Your VPC in the Amazon Virtual Private Cloud User Guide.

Returns:

  • (Array<String>)


77
78
79
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 77

def security_groups
  data[:security_groups]
end

#spot_priceString

The maximum hourly price to be paid for any Spot Instance launched to fulfill the request. Spot Instances are launched when the price you specify exceeds the current Spot price.

For more information, see Launching Spot Instances in Your Auto Scaling Group in the Amazon EC2 Auto Scaling User Guide.

Returns:

  • (String)


191
192
193
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 191

def spot_price
  data[:spot_price]
end

#user_dataString

The Base64-encoded user data to make available to the launched EC2 instances.

For more information, see Instance Metadata and User Data in the Amazon EC2 User Guide for Linux Instances.

Returns:

  • (String)


123
124
125
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 123

def user_data
  data[:user_data]
end

#wait_until(options = {}, &block) ⇒ Resource

Deprecated.

Use [Aws::AutoScaling::Client] #wait_until instead

Note:

The waiting operation is performed on a copy. The original resource remains unchanged

Waiter polls an API operation until a resource enters a desired state.

Basic Usage

Waiter will polls until it is successful, it fails by entering a terminal state, or until a maximum number of attempts are made.

# polls in a loop until condition is true
resource.wait_until(options) {|resource| condition}

Example

instance.wait_until(max_attempts:10, delay:5) {|instance| instance.state.name == 'running' }

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. The waiting condition is set by passing a block to #wait_until:

# poll for ~25 seconds
resource.wait_until(max_attempts:5,delay:5) {|resource|...}

Callbacks

You can be notified before each polling attempt and before each delay. If you throw :success or :failure from these callbacks, it will terminate the waiter.

started_at = Time.now
# poll for 1 hour, instead of a number of attempts
proc = Proc.new do |attempts, response|
  throw :failure if Time.now - started_at > 3600
end

  # disable max attempts
instance.wait_until(before_wait:proc, max_attempts:nil) {...}

Handling Errors

When a waiter is successful, it returns the Resource. When a waiter fails, it raises an error.

begin
  resource.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

attempts attempt in seconds invoked before each attempt invoked before each wait

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :max_attempts (Integer) — default: 10

    Maximum number of

  • :delay (Integer) — default: 10

    Delay between each

  • :before_attempt (Proc) — default: nil

    Callback

  • :before_wait (Proc) — default: nil

    Callback

Returns:

  • (Resource)

    if the waiter was successful

Raises:

  • (Aws::Waiters::Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

    yet successful.

  • (Aws::Waiters::Errors::UnexpectedError)

    Raised when an error is encountered while polling for a resource that is not expected.

  • (NotImplementedError)

    Raised when the resource does not



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'gems/aws-sdk-autoscaling/lib/aws-sdk-autoscaling/launch_configuration.rb', line 372

def wait_until(options = {}, &block)
  self_copy = self.dup
  attempts = 0
  options[:max_attempts] = 10 unless options.key?(:max_attempts)
  options[:delay] ||= 10
  options[:poller] = Proc.new do
    attempts += 1
    if block.call(self_copy)
      [:success, self_copy]
    else
      self_copy.reload unless attempts == options[:max_attempts]
      :retry
    end
  end
  Aws::Waiters::Waiter.new(options).wait({})
end