class Aws::AutoScaling::LaunchConfiguration
Public Class Methods
@overload def initialize(name, options = {})
@param [String] name @option options [Client] :client
@overload def initialize(options = {})
@option options [required, String] :name @option options [Client] :client
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 22 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) @waiter_block_warned = false end
Public Instance Methods
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*.
[1]: docs.aws.amazon.com/autoscaling/ec2/userguide/asg-in-vpc.html @return [Boolean]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 234 def associate_public_ip_address data[:associate_public_ip_address] end
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*.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html @return [Array<Types::BlockDeviceMapping>]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 160 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*.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/vpc-classiclink.html [2]: docs.aws.amazon.com/autoscaling/ec2/userguide/asg-in-vpc.html#as-ClassicLink @return [String]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 91 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*.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/vpc-classiclink.html [2]: docs.aws.amazon.com/autoscaling/ec2/userguide/asg-in-vpc.html#as-ClassicLink @return [Array<String>]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 107 def classic_link_vpc_security_groups data[:classic_link_vpc_security_groups] end
@return [Client]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 268 def client @client end
The creation date and time for the launch configuration. @return [Time]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 208 def created_time data[:created_time] end
@return [Types::LaunchConfiguration]
Returns the data for this {LaunchConfiguration}. Calls {Client#describe_launch_configurations} if {#data_loaded?} is `false`.
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 288 def data load unless @data @data end
@return [Boolean]
Returns `true` if this resource is loaded. Accessing attributes or {#data} on an unloaded resource will trigger a call to {#load}.
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 296 def data_loaded? !!@data end
@example Request syntax with placeholder values
launch_configuration.delete()
@param [Hash] options ({}) @return [EmptyStructure]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 404 def delete(options = {}) options = options.merge(launch_configuration_name: @name) resp = @client.delete_launch_configuration(options) resp.data end
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*.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSOptimized.html @return [Boolean]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 221 def ebs_optimized data[:ebs_optimized] end
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*.
[1]: docs.aws.amazon.com/autoscaling/ec2/userguide/us-iam-role.html @return [String]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 202 def iam_instance_profile data[:iam_instance_profile] end
@deprecated @api private
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 412 def identifiers { name: @name } end
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*.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html @return [String]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 52 def image_id data[:image_id] end
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*.
[1]: docs.aws.amazon.com/autoscaling/latest/userguide/enable-as-instance-metrics.html @return [Types::InstanceMonitoring]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 174 def instance_monitoring data[:instance_monitoring] end
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*.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html#AvailableInstanceTypes @return [String]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 136 def instance_type data[:instance_type] end
The ID of the kernel associated with the AMI. @return [String]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 142 def kernel_id data[:kernel_id] end
The name of the key pair.
For more information, see [Amazon EC2 Key Pairs] in the *Amazon EC2 User Guide for Linux Instances*.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html @return [String]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 65 def key_name data[:key_name] end
The Amazon Resource
Name (ARN) of the launch configuration. @return [String]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 40 def launch_configuration_arn data[:launch_configuration_arn] end
Loads, or reloads {#data} for the current {LaunchConfiguration}. Returns `self` making it possible to chain methods.
launch_configuration.reload.data
@return [self]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 278 def load resp = @client.describe_launch_configurations(launch_configuration_names: [@name]) @data = resp.launch_configurations[0] self end
The metadata options for the instances. For more information, see
- Configuring the
Instance
Metadata Options][1 -
in the *Amazon EC2 Auto
Scaling User Guide*.
[1]: docs.aws.amazon.com/autoscaling/ec2/userguide/create-launch-config.html#launch-configurations-imds @return [Types::InstanceMetadataOptions]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 261 def metadata_options data[:metadata_options] end
@return [String]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 33 def name @name end
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 [Configuring instance tenancy with Amazon EC2 Auto Scaling] in the *Amazon EC2 Auto Scaling User Guide*.
[1]: docs.aws.amazon.com/autoscaling/ec2/userguide/auto-scaling-dedicated-instances.html @return [String]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 249 def placement_tenancy data[:placement_tenancy] end
The ID of the RAM disk associated with the AMI. @return [String]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 148 def ramdisk_id data[:ramdisk_id] end
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*.
[1]: docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_SecurityGroups.html @return [Array<String>]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 77 def security_groups data[:security_groups] end
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
- Requesting Spot Instances][1
-
in the *Amazon EC2 Auto Scaling User
Guide*.
[1]: docs.aws.amazon.com/autoscaling/ec2/userguide/asg-launch-spot-instances.html @return [String]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 188 def spot_price data[:spot_price] end
The user data to make available to the launched EC2 instances. For more information, see [Instance metadata and user data] (Linux) and
Instance
metadata and user data][2-
(Windows). If you are using a
command line tool, base64-encoding is performed for you, and you can load the text from a file. Otherwise, you must provide base64-encoded text. User data is limited to 16 KB.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html [2]: docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-instance-metadata.html @return [String]
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 123 def user_data data[:user_data] end
@deprecated Use [Aws::AutoScaling::Client] wait_until
instead
Waiter polls an API operation until a resource enters a desired state.
@note The waiting operation is performed on a copy. The original resource
remains unchanged.
## 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) do |instance| instance.state.name == 'running' end
## 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
@yieldparam [Resource] resource to be used in the waiting condition.
@raise [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.
@raise [Aws::Waiters::Errors::UnexpectedError] Raised when an error is
encountered while polling for a resource that is not expected.
@raise [NotImplementedError] Raised when the resource does not
@option options [Integer] :max_attempts (10) Maximum number of attempts @option options [Integer] :delay (10) Delay between each attempt in seconds @option options [Proc] :before_attempt (nil) Callback invoked before each attempt @option options [Proc] :before_wait (nil) Callback invoked before each wait @return [Resource] if the waiter was successful
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 380 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
Private Instance Methods
# File lib/aws-sdk-autoscaling/launch_configuration.rb, line 419 def extract_name(args, options) value = args[0] || options.delete(:name) case value when String then value when nil then raise ArgumentError, "missing required option :name" else msg = "expected :name to be a String, got #{value.class}" raise ArgumentError, msg end end