Class: Aws::OpsWorks::Stack
- Inherits:
-
Object
- Object
- Aws::OpsWorks::Stack
- Extended by:
- Deprecations
- Defined in:
- 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 Amazon Web Services Region, such as ‘ap-northeast-2`.
-
#service_role_arn ⇒ String
The stack 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 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
- #identifiers ⇒ Object deprecated private Deprecated.
- #layers(options = {}) ⇒ Layer::Collection
- #summary ⇒ StackSummary
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 '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.
218 219 220 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 218 def agent_version data[:agent_version] end |
#arn ⇒ String
The stack’s ARN.
51 52 53 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 51 def arn data[:arn] end |
#attributes ⇒ Hash<String,String>
The stack’s attributes.
75 76 77 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 75 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].
[1]: docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-creating.html
160 161 162 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 160 def chef_configuration data[:chef_configuration] end |
#client ⇒ Client
225 226 227 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 225 def client @client end |
#configuration_manager ⇒ Types::StackConfigurationManager
The configuration manager.
148 149 150 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 148 def configuration_manager data[:configuration_manager] end |
#create_layer(options = {}) ⇒ Layer
515 516 517 518 519 520 521 522 523 524 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 515 def create_layer( = {}) = .merge(stack_id: @id) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.create_layer() end Layer.new( id: resp.data.layer_id, client: @client ) end |
#created_at ⇒ String
The date when the stack was created.
199 200 201 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 199 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].
[1]: docs.aws.amazon.com/opsworks/latest/userguide/workingapps-creating.html [2]: docs.aws.amazon.com/opsworks/latest/userguide/workingcookbook.html
186 187 188 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 186 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:
‘“”value1“, ”key2“: ”value2“,…”`
For more information on custom JSON, see [Use Custom JSON to Modify the Stack Configuration Attributes].
[1]: docs.aws.amazon.com/opsworks/latest/userguide/workingstacks-json.html
142 143 144 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 142 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`.
247 248 249 250 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 247 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
255 256 257 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 255 def data_loaded? !!@data end |
#default_availability_zone ⇒ String
The stack’s default Availability Zone. For more information, see [Regions and Endpoints].
116 117 118 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 116 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].
[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
93 94 95 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 93 def default_instance_profile_arn data[:default_instance_profile_arn] end |
#default_os ⇒ String
The stack’s default operating system.
99 100 101 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 99 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].
[1]: docs.aws.amazon.com/AWSEC2/latest/UserGuide/ComponentsAMIs.html#storage-for-the-root-device
211 212 213 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 211 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.
193 194 195 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 193 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.
123 124 125 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 123 def default_subnet_id data[:default_subnet_id] end |
#delete(options = {}) ⇒ EmptyStructure
531 532 533 534 535 536 537 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 531 def delete( = {}) = .merge(stack_id: @id) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.delete_stack() end resp.data end |
#hostname_theme ⇒ String
The stack host name theme, with spaces replaced by underscores.
105 106 107 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 105 def hostname_theme data[:hostname_theme] end |
#id ⇒ String
33 34 35 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 33 def id @id 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.
581 582 583 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 581 def identifiers { id: @id } end |
#layers(options = {}) ⇒ Layer::Collection
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 552 def layers( = {}) batches = Enumerator.new do |y| batch = [] = .merge(stack_id: @id) resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.describe_layers() end 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
235 236 237 238 239 240 241 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 235 def load resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.describe_stacks(stack_ids: [@id]) end @data = resp.stacks[0] self end |
#name ⇒ String
The stack name. Stack names can be a maximum of 64 characters.
45 46 47 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 45 def name data[:name] end |
#region ⇒ String
The stack Amazon Web Services Region, such as ‘ap-northeast-2`. For more information about Amazon Web Services Regions, see [Regions and Endpoints].
63 64 65 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 63 def region data[:region] end |
#service_role_arn ⇒ String
The stack Identity and Access Management (IAM) role.
81 82 83 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 81 def service_role_arn data[:service_role_arn] end |
#stack_id ⇒ String
The stack ID.
39 40 41 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 39 def stack_id data[:stack_id] end |
#summary ⇒ StackSummary
572 573 574 575 576 577 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 572 def summary StackSummary.new( stack_id: @id, client: @client ) end |
#use_custom_cookbooks ⇒ Boolean
Whether the stack uses custom cookbooks.
166 167 168 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 166 def use_custom_cookbooks data[:use_custom_cookbooks] end |
#use_opsworks_security_groups ⇒ Boolean
Whether the stack automatically associates the OpsWorks Stacks built-in security groups with the stack’s layers.
173 174 175 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 173 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.
69 70 71 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 69 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
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/aws-sdk-opsworks/stack.rb', line 339 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 |