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
[EC2-VPC] Indicates whether to assign a public IP address to each instance.
-
#block_device_mappings ⇒ Array<Types::BlockDeviceMapping>
A block device mapping, which specifies the block devices for the instance.
-
#classic_link_vpc_id ⇒ String
The ID of a ClassicLink-enabled VPC to link your EC2-Classic instances to.
-
#classic_link_vpc_security_groups ⇒ Array<String>
The IDs of one or more security groups for the VPC specified in ‘ClassicLinkVPCId`.
-
#created_time ⇒ Time
The creation date and time for the launch configuration.
-
#ebs_optimized ⇒ Boolean
Controls whether the instance is optimized for EBS I/O (‘true`) or not (`false`).
-
#iam_instance_profile ⇒ String
The name or 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).
-
#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.
- #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>
The security groups to associate with the instances.
-
#spot_price ⇒ String
The price to bid when launching Spot Instances.
-
#user_data ⇒ String
The user data available to the 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 = {}, &block) ⇒ 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.
19 20 21 22 23 24 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 19 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @name = extract_name(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() end |
Instance Method Details
#associate_public_ip_address ⇒ Boolean
[EC2-VPC] Indicates whether to assign a public IP address to each instance.
152 153 154 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 152 def associate_public_ip_address data[:associate_public_ip_address] end |
#block_device_mappings ⇒ Array<Types::BlockDeviceMapping>
A block device mapping, which specifies the block devices for the instance.
112 113 114 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 112 def block_device_mappings data[:block_device_mappings] end |
#classic_link_vpc_id ⇒ String
The ID of a ClassicLink-enabled VPC to link your EC2-Classic instances to. This parameter can only be used if you are launching EC2-Classic instances. For more information, see [ClassicLink] in the *Amazon Elastic Compute Cloud User Guide*.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/vpc-classiclink.html
67 68 69 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 67 def classic_link_vpc_id data[:classic_link_vpc_id] end |
#classic_link_vpc_security_groups ⇒ Array<String>
The IDs of one or more security groups for the VPC specified in ‘ClassicLinkVPCId`. This parameter is required if you specify a ClassicLink-enabled VPC, and cannot be used otherwise. For more information, see [ClassicLink] in the *Amazon Elastic Compute Cloud User Guide*.
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/vpc-classiclink.html
81 82 83 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 81 def classic_link_vpc_security_groups data[:classic_link_vpc_security_groups] end |
#client ⇒ Client
167 168 169 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 167 def client @client end |
#created_time ⇒ Time
The creation date and time for the launch configuration.
138 139 140 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 138 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`.
187 188 189 190 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 187 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
195 196 197 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 195 def data_loaded? !!@data end |
#delete(options = {}) ⇒ EmptyStructure
301 302 303 304 305 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 301 def delete( = {}) = .merge(launch_configuration_name: @name) resp = @client.delete_launch_configuration() resp.data end |
#ebs_optimized ⇒ Boolean
Controls whether the instance is optimized for EBS I/O (‘true`) or not (`false`).
145 146 147 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 145 def ebs_optimized data[:ebs_optimized] end |
#iam_instance_profile ⇒ String
The name or Amazon Resource Name (ARN) of the instance profile associated with the IAM role for the instance.
132 133 134 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 132 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.
309 310 311 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 309 def identifiers { name: @name } end |
#image_id ⇒ String
The ID of the Amazon Machine Image (AMI).
42 43 44 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 42 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.
119 120 121 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 119 def instance_monitoring data[:instance_monitoring] end |
#instance_type ⇒ String
The instance type for the instances.
93 94 95 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 93 def instance_type data[:instance_type] end |
#kernel_id ⇒ String
The ID of the kernel associated with the AMI.
99 100 101 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 99 def kernel_id data[:kernel_id] end |
#key_name ⇒ String
The name of the key pair.
48 49 50 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 48 def key_name data[:key_name] end |
#launch_configuration_arn ⇒ String
The Amazon Resource Name (ARN) of the launch configuration.
36 37 38 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 36 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
177 178 179 180 181 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 177 def load resp = @client.describe_launch_configurations(launch_configuration_names: [@name]) @data = resp.launch_configurations[0] self end |
#name ⇒ String Also known as: launch_configuration_name
29 30 31 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 29 def name @name end |
#placement_tenancy ⇒ String
The tenancy of the instance, either ‘default` or `dedicated`. An instance with `dedicated` tenancy runs in an isolated, single-tenant hardware and can only be launched into a VPC.
160 161 162 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 160 def placement_tenancy data[:placement_tenancy] end |
#ramdisk_id ⇒ String
The ID of the RAM disk associated with the AMI.
105 106 107 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 105 def ramdisk_id data[:ramdisk_id] end |
#security_groups ⇒ Array<String>
The security groups to associate with the instances.
54 55 56 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 54 def security_groups data[:security_groups] end |
#spot_price ⇒ String
The price to bid when launching Spot Instances.
125 126 127 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 125 def spot_price data[:spot_price] end |
#user_data ⇒ String
The user data available to the instances.
87 88 89 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 87 def user_data data[:user_data] end |
#wait_until(options = {}, &block) ⇒ 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) {|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
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/aws-sdk-autoscaling/launch_configuration.rb', line 277 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::Waiters::Waiter.new().wait({}) end |