Class: Aws::OpsWorks::Stack
- Inherits:
-
Object
- Object
- Aws::OpsWorks::Stack
- Defined in:
- gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
-
#agent_version ⇒ String
The agent version.
-
#arn ⇒ String
The stack's ARN.
-
#attributes ⇒ Hash<String,String>
The stack's attributes.
-
#chef_configuration ⇒ Types::ChefConfiguration
A
ChefConfiguration
object that specifies whether to enable Berkshelf and the Berkshelf version. -
#configuration_manager ⇒ Types::StackConfigurationManager
The configuration manager.
-
#created_at ⇒ String
The date when the stack was created.
-
#custom_cookbooks_source ⇒ Types::Source
Contains the information required to retrieve an app or cookbook from a repository.
-
#custom_json ⇒ String
A JSON object that contains user-defined attributes to be added to the stack configuration and deployment attributes.
-
#default_availability_zone ⇒ String
The stack's default Availability Zone.
-
#default_instance_profile_arn ⇒ String
The ARN of an IAM profile that is the default profile for all of the stack's EC2 instances.
-
#default_os ⇒ String
The stack's default operating system.
-
#default_root_device_type ⇒ String
The default root device type.
-
#default_ssh_key_name ⇒ String
A default Amazon EC2 key pair for the stack's instances.
-
#default_subnet_id ⇒ String
The default subnet ID; applicable only if the stack is running in a VPC.
-
#hostname_theme ⇒ String
The stack host name theme, with spaces replaced by underscores.
-
#id ⇒ String
-
#name ⇒ String
The stack name.
-
#region ⇒ String
The stack AWS region, such as "ap-northeast-2".
-
#service_role_arn ⇒ String
The stack AWS Identity and Access Management (IAM) role.
-
#stack_id ⇒ String
The stack ID.
-
#use_custom_cookbooks ⇒ Boolean
Whether the stack uses custom cookbooks.
-
#use_opsworks_security_groups ⇒ Boolean
Whether the stack automatically associates the AWS OpsWorks Stacks built-in security groups with the stack's layers.
-
#vpc_id ⇒ String
The VPC ID; applicable only if the stack is running in a VPC.
Actions collapse
Associations collapse
Instance Method Summary collapse
-
#client ⇒ Client
-
#data ⇒ Types::Stack
Returns the data for this Stack.
-
#data_loaded? ⇒ Boolean
Returns
true
if this resource is loaded. -
#initialize(*args) ⇒ Stack
constructor
A new instance of Stack.
- #load ⇒ self (also: #reload)
-
#wait_until(options = {}) {|resource| ... } ⇒ Resource
deprecated
Deprecated.
Use [Aws::OpsWorks::Client] #wait_until instead
Constructor Details
#initialize(id, options = {}) ⇒ Stack #initialize(options = {}) ⇒ Stack
Returns a new instance of Stack.
22 23 24 25 26 27 28 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 22 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @id = extract_id(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() @waiter_block_warned = false end |
Instance Method Details
#agent_version ⇒ String
The agent version. This parameter is set to LATEST
for auto-update.
or a version number for a fixed agent version.
217 218 219 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 217 def agent_version data[:agent_version] end |
#arn ⇒ String
The stack's ARN.
51 52 53 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 51 def arn data[:arn] end |
#attributes ⇒ Hash<String,String>
The stack's attributes.
74 75 76 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 74 def attributes data[:attributes] end |
#chef_configuration ⇒ Types::ChefConfiguration
A ChefConfiguration
object that specifies whether to enable
Berkshelf and the Berkshelf version. For more information, see Create
a New Stack.
159 160 161 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 159 def chef_configuration data[:chef_configuration] end |
#client ⇒ Client
224 225 226 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 224 def client @client end |
#configuration_manager ⇒ Types::StackConfigurationManager
The configuration manager.
147 148 149 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 147 def configuration_manager data[:configuration_manager] end |
#create_layer(options = {}) ⇒ Layer
509 510 511 512 513 514 515 516 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 509 def create_layer( = {}) = .merge(stack_id: @id) resp = @client.create_layer() Layer.new( id: resp.data.layer_id, client: @client ) end |
#created_at ⇒ String
The date when the stack was created.
198 199 200 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 198 def created_at data[:created_at] end |
#custom_cookbooks_source ⇒ Types::Source
Contains the information required to retrieve an app or cookbook from a repository. For more information, see Adding Apps or Cookbooks and Recipes.
185 186 187 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 185 def custom_cookbooks_source data[:custom_cookbooks_source] end |
#custom_json ⇒ String
A JSON object that contains user-defined attributes to be added to the stack configuration and deployment attributes. You can use custom JSON to override the corresponding default stack configuration attribute values or to pass data to recipes. The string should be in the following format:
"\{"key1": "value1", "key2": "value2",...\}"
For more information on custom JSON, see Use Custom JSON to Modify the Stack Configuration Attributes.
141 142 143 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 141 def custom_json data[:custom_json] end |
#data ⇒ Types::Stack
Returns the data for this Aws::OpsWorks::Stack. Calls
Client#describe_stacks if #data_loaded? is false
.
244 245 246 247 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 244 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
252 253 254 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 252 def data_loaded? !!@data end |
#default_availability_zone ⇒ String
The stack's default Availability Zone. For more information, see Regions and Endpoints.
115 116 117 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 115 def default_availability_zone data[:default_availability_zone] end |
#default_instance_profile_arn ⇒ String
The ARN of an IAM profile that is the default profile for all of the stack's EC2 instances. For more information about IAM ARNs, see Using Identifiers.
92 93 94 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 92 def default_instance_profile_arn data[:default_instance_profile_arn] end |
#default_os ⇒ String
The stack's default operating system.
98 99 100 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 98 def default_os data[:default_os] end |
#default_root_device_type ⇒ String
The default root device type. This value is used by default for all instances in the stack, but you can override it when you create an instance. For more information, see Storage for the Root Device.
210 211 212 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 210 def default_root_device_type data[:default_root_device_type] end |
#default_ssh_key_name ⇒ String
A default Amazon EC2 key pair for the stack's instances. You can override this value when you create or update an instance.
192 193 194 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 192 def default_ssh_key_name data[:default_ssh_key_name] end |
#default_subnet_id ⇒ String
The default subnet ID; applicable only if the stack is running in a VPC.
122 123 124 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 122 def default_subnet_id data[:default_subnet_id] end |
#delete(options = {}) ⇒ EmptyStructure
523 524 525 526 527 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 523 def delete( = {}) = .merge(stack_id: @id) resp = @client.delete_stack() resp.data end |
#hostname_theme ⇒ String
The stack host name theme, with spaces replaced by underscores.
104 105 106 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 104 def hostname_theme data[:hostname_theme] end |
#id ⇒ String
33 34 35 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 33 def id @id end |
#layers(options = {}) ⇒ Layer::Collection
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 542 def layers( = {}) batches = Enumerator.new do |y| batch = [] = .merge(stack_id: @id) resp = @client.describe_layers() resp.data.layers.each do |l| batch << Layer.new( id: l.layer_id, data: l, client: @client ) end y.yield(batch) end Layer::Collection.new(batches) end |
#load ⇒ self Also known as: reload
Loads, or reloads #data for the current Aws::OpsWorks::Stack.
Returns self
making it possible to chain methods.
stack.reload.data
234 235 236 237 238 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 234 def load resp = @client.describe_stacks(stack_ids: [@id]) @data = resp.stacks[0] self end |
#name ⇒ String
The stack name.
45 46 47 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 45 def name data[:name] end |
#region ⇒ String
The stack AWS region, such as "ap-northeast-2". For more information about AWS regions, see Regions and Endpoints.
62 63 64 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 62 def region data[:region] end |
#service_role_arn ⇒ String
The stack AWS Identity and Access Management (IAM) role.
80 81 82 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 80 def service_role_arn data[:service_role_arn] end |
#stack_id ⇒ String
The stack ID.
39 40 41 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 39 def stack_id data[:stack_id] end |
#summary ⇒ StackSummary
560 561 562 563 564 565 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 560 def summary StackSummary.new( stack_id: @id, client: @client ) end |
#use_custom_cookbooks ⇒ Boolean
Whether the stack uses custom cookbooks.
165 166 167 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 165 def use_custom_cookbooks data[:use_custom_cookbooks] end |
#use_opsworks_security_groups ⇒ Boolean
Whether the stack automatically associates the AWS OpsWorks Stacks built-in security groups with the stack's layers.
172 173 174 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 172 def use_opsworks_security_groups data[:use_opsworks_security_groups] end |
#vpc_id ⇒ String
The VPC ID; applicable only if the stack is running in a VPC.
68 69 70 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 68 def vpc_id data[:vpc_id] end |
#wait_until(options = {}) {|resource| ... } ⇒ Resource
Use [Aws::OpsWorks::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
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/stack.rb', line 336 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 |