Class: Aws::AutoScaling::LaunchConfiguration
- Inherits:
-
Object
- Object
- Aws::AutoScaling::LaunchConfiguration
- Extended by:
- Deprecations
- Defined in:
- lib/aws-sdk-autoscaling/launch_configuration.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
-
#associate_public_ip_address ⇒ Boolean
Specifies whether to assign a public IPv4 address to the group’s instances.
-
#block_device_mappings ⇒ Array<Types::BlockDeviceMapping>
The block device mapping entries that define the block devices to attach to the instances at launch.
-
#classic_link_vpc_id ⇒ String
Available for backward compatibility.
-
#classic_link_vpc_security_groups ⇒ Array<String>
Available for backward compatibility.
-
#created_time ⇒ Time
The creation date and time for the launch configuration.
-
#ebs_optimized ⇒ Boolean
Specifies whether the launch configuration is optimized for EBS I/O (‘true`) or not (`false`).
-
#iam_instance_profile ⇒ String
The name or the Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance.
-
#image_id ⇒ String
The ID of the Amazon Machine Image (AMI) to use to launch your EC2 instances.
-
#instance_monitoring ⇒ Types::InstanceMonitoring
Controls whether instances in this group are launched with detailed (‘true`) or basic (`false`) monitoring.
-
#instance_type ⇒ String
The instance type for the instances.
-
#kernel_id ⇒ String
The ID of the kernel associated with the AMI.
-
#key_name ⇒ String
The name of the key pair.
-
#launch_configuration_arn ⇒ String
The Amazon Resource Name (ARN) of the launch configuration.
-
#metadata_options ⇒ Types::InstanceMetadataOptions
The metadata options for the instances.
- #name ⇒ String (also: #launch_configuration_name)
-
#placement_tenancy ⇒ String
The tenancy of the instance, either ‘default` or `dedicated`.
-
#ramdisk_id ⇒ String
The ID of the RAM disk associated with the AMI.
-
#security_groups ⇒ Array<String>
A list that contains the security groups to assign to the instances in the Auto Scaling group.
-
#spot_price ⇒ String
The maximum hourly price to be paid for any Spot Instance launched to fulfill the request.
-
#user_data ⇒ String
The user data to make available to the launched EC2 instances.
Actions collapse
- #delete(options = {}) ⇒ EmptyStructure
- #identifiers ⇒ Object deprecated private Deprecated.
Instance Method Summary collapse
- #client ⇒ Client
-
#data ⇒ Types::LaunchConfiguration
Returns the data for this LaunchConfiguration.
-
#data_loaded? ⇒ Boolean
Returns ‘true` if this resource is loaded.
-
#initialize(*args) ⇒ LaunchConfiguration
constructor
A new instance of LaunchConfiguration.
-
#load ⇒ self
(also: #reload)
Loads, or reloads #data for the current LaunchConfiguration.
-
#wait_until(options = {}) {|resource| ... } ⇒ Resource
deprecated
Deprecated.
Use [Aws::AutoScaling::Client] #wait_until instead
Constructor Details
#initialize(name, options = {}) ⇒ LaunchConfiguration #initialize(options = {}) ⇒ LaunchConfiguration
Returns a new instance of LaunchConfiguration.
22 23 24 25 26 27 28 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 22 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @name = extract_name(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() @waiter_block_warned = false end |
Instance Method Details
#associate_public_ip_address ⇒ Boolean
Specifies whether to assign a public IPv4 address to the group’s instances. If the instance is launched into a default subnet, the default is to assign a public IPv4 address, unless you disabled the option to assign a public IPv4 address on the subnet. If the instance is launched into a nondefault subnet, the default is not to assign a public IPv4 address, unless you enabled the option to assign a public IPv4 address on the subnet. For more information, see [Provide network connectivity for your Auto Scaling instances using Amazon VPC] in the *Amazon EC2 Auto Scaling User Guide*.
[1]: docs.aws.amazon.com/autoscaling/ec2/userguide/asg-in-vpc.html
223 224 225 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 223 def associate_public_ip_address data[:associate_public_ip_address] end |
#block_device_mappings ⇒ Array<Types::BlockDeviceMapping>
The block device mapping entries that define the block devices to attach to the instances at launch. By default, the block devices specified in the block device mapping for the AMI are used. For more information, see [Block device mappings] in the *Amazon EC2 User Guide for Linux Instances*.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html
144 145 146 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 144 def block_device_mappings data[:block_device_mappings] end |
#classic_link_vpc_id ⇒ String
Available for backward compatibility.
84 85 86 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 84 def classic_link_vpc_id data[:classic_link_vpc_id] end |
#classic_link_vpc_security_groups ⇒ Array<String>
Available for backward compatibility.
90 91 92 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 90 def classic_link_vpc_security_groups data[:classic_link_vpc_security_groups] end |
#client ⇒ Client
250 251 252 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 250 def client @client end |
#created_time ⇒ Time
The creation date and time for the launch configuration.
192 193 194 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 192 def created_time data[:created_time] end |
#data ⇒ Types::LaunchConfiguration
Returns the data for this Aws::AutoScaling::LaunchConfiguration. Calls Client#describe_launch_configurations if #data_loaded? is ‘false`.
272 273 274 275 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 272 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
280 281 282 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 280 def data_loaded? !!@data end |
#delete(options = {}) ⇒ EmptyStructure
390 391 392 393 394 395 396 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 390 def delete( = {}) = .merge(launch_configuration_name: @name) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.delete_launch_configuration() end resp.data end |
#ebs_optimized ⇒ Boolean
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/ebs-optimized.html
205 206 207 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 205 def ebs_optimized data[:ebs_optimized] end |
#iam_instance_profile ⇒ String
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
186 187 188 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 186 def iam_instance_profile data[:iam_instance_profile] end |
#identifiers ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
400 401 402 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 400 def identifiers { name: @name } end |
#image_id ⇒ String
The ID of the Amazon Machine Image (AMI) to use to launch your EC2 instances. For more information, see [Find a Linux AMI] in the *Amazon EC2 User Guide for Linux Instances*.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html
52 53 54 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 52 def image_id data[:image_id] end |
#instance_monitoring ⇒ Types::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*.
[1]: docs.aws.amazon.com/autoscaling/latest/userguide/enable-as-instance-metrics.html
158 159 160 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 158 def instance_monitoring data[:instance_monitoring] end |
#instance_type ⇒ String
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
118 119 120 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 118 def instance_type data[:instance_type] end |
#kernel_id ⇒ String
The ID of the kernel associated with the AMI.
124 125 126 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 124 def kernel_id data[:kernel_id] end |
#key_name ⇒ String
The name of the key pair.
For more information, see [Amazon EC2 key pairs and Amazon EC2 instances] in the *Amazon EC2 User Guide for Linux Instances*.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html
65 66 67 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 65 def key_name data[:key_name] end |
#launch_configuration_arn ⇒ String
The Amazon Resource Name (ARN) of the launch configuration.
40 41 42 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 40 def launch_configuration_arn data[:launch_configuration_arn] end |
#load ⇒ self 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
260 261 262 263 264 265 266 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 260 def load resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.describe_launch_configurations(launch_configuration_names: [@name]) end @data = resp.launch_configurations[0] self end |
#metadata_options ⇒ Types::InstanceMetadataOptions
The metadata options for the instances. For more information, see
- Configure 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
243 244 245 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 243 def data[:metadata_options] end |
#name ⇒ String Also known as: launch_configuration_name
33 34 35 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 33 def name @name end |
#placement_tenancy ⇒ String
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.
231 232 233 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 231 def placement_tenancy data[:placement_tenancy] end |
#ramdisk_id ⇒ String
The ID of the RAM disk associated with the AMI.
130 131 132 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 130 def ramdisk_id data[:ramdisk_id] end |
#security_groups ⇒ Array<String>
A list that contains the security groups to assign to the instances in the Auto Scaling group. For more information, see [Control traffic to your Amazon Web Services resources using security groups] in the *Amazon Virtual Private Cloud User Guide*.
[1]: docs.aws.amazon.com/vpc/latest/userguide/vpc-security-groups.html
78 79 80 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 78 def security_groups data[:security_groups] end |
#spot_price ⇒ String
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 for fault-tolerant and flexible applications] in the *Amazon EC2 Auto Scaling User Guide*.
[1]: docs.aws.amazon.com/autoscaling/ec2/userguide/launch-template-spot-instances.html
172 173 174 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 172 def spot_price data[:spot_price] end |
#user_data ⇒ String
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
106 107 108 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 106 def user_data data[:user_data] end |
#wait_until(options = {}) {|resource| ... } ⇒ Resource
Use [Aws::AutoScaling::Client] #wait_until instead
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() {|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
attempts attempt in seconds invoked before each attempt invoked before each wait
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 364 def wait_until( = {}, &block) self_copy = self.dup attempts = 0 [:max_attempts] = 10 unless .key?(:max_attempts) [:delay] ||= 10 [:poller] = Proc.new do attempts += 1 if block.call(self_copy) [:success, self_copy] else self_copy.reload unless attempts == [:max_attempts] :retry end end Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do Aws::Waiters::Waiter.new().wait({}) end end |