You are viewing documentation for version 3 of the AWS SDK for Ruby. Version 2 documentation can be found here.

Class: Aws::OpsWorks::Layer

Inherits:
Object
  • Object
show all
Defined in:
gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb

Defined Under Namespace

Classes: Collection

Actions collapse

Associations collapse

Read-Only Attributes collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, options = {}) ⇒ Layer #initialize(options = {}) ⇒ Layer

Returns a new instance of Layer

Overloads:

  • #initialize(id, options = {}) ⇒ Layer

    Parameters:

    • id (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ Layer

    Options Hash (options):

    • :id (required, String)
    • :client (Client)


19
20
21
22
23
24
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 19

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @id = extract_id(args, options)
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
end

Instance Method Details

#arnString

The Amazon Resource Number (ARN) of a layer.

Returns:

  • (String)


35
36
37
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 35

def arn
  data[:arn]
end

#attributesHash<String,String>

The layer attributes.

For the HaproxyStatsPassword, MysqlRootPassword, and GangliaPassword attributes, AWS OpsWorks Stacks returns *****FILTERED***** instead of the actual value

For an ECS Cluster layer, AWS OpsWorks Stacks the EcsClusterArn attribute is set to the cluster's ARN.

Returns:

  • (Hash<String,String>)


78
79
80
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 78

def attributes
  data[:attributes]
end

#auto_assign_elastic_ipsBoolean

Whether to automatically assign an Elastic IP address to the layer's instances. For more information, see How to Edit a Layer.

Returns:

  • (Boolean)


147
148
149
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 147

def auto_assign_elastic_ips
  data[:auto_assign_elastic_ips]
end

#auto_assign_public_ipsBoolean

For stacks that are running in a VPC, whether to automatically assign a public IP address to the layer's instances. For more information, see How to Edit a Layer.

Returns:

  • (Boolean)


159
160
161
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 159

def auto_assign_public_ips
  data[:auto_assign_public_ips]
end

#clientClient

Returns:



227
228
229
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 227

def client
  @client
end

#cloud_watch_logs_configurationTypes::CloudWatchLogsConfiguration

The Amazon CloudWatch Logs configuration settings for the layer.



84
85
86
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 84

def cloud_watch_logs_configuration
  data[:cloud_watch_logs_configuration]
end

#created_atString

Date when the layer was created.

Returns:

  • (String)


191
192
193
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 191

def created_at
  data[:created_at]
end

#custom_instance_profile_arnString

The ARN of the default IAM profile to be used for the layer's EC2 instances. For more information about IAM ARNs, see Using Identifiers.

Returns:

  • (String)


96
97
98
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 96

def custom_instance_profile_arn
  data[:custom_instance_profile_arn]
end

#custom_jsonString

A JSON formatted string containing the layer's custom stack configuration and deployment attributes.

Returns:

  • (String)


103
104
105
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 103

def custom_json
  data[:custom_json]
end

#custom_recipesTypes::Recipes

A LayerCustomRecipes object that specifies the layer's custom recipes.

Returns:



185
186
187
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 185

def custom_recipes
  data[:custom_recipes]
end

#custom_security_group_idsArray<String>

An array containing the layer's custom security group IDs.

Returns:

  • (Array<String>)


109
110
111
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 109

def custom_security_group_ids
  data[:custom_security_group_ids]
end

#dataTypes::Layer

Returns the data for this Aws::OpsWorks::Layer. Calls Client#describe_layers if #data_loaded? is false.

Returns:



247
248
249
250
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 247

def data
  load unless @data
  @data
end

#data_loaded?Boolean

Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns true if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



255
256
257
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 255

def data_loaded?
  !!@data
end

#default_recipesTypes::Recipes

AWS OpsWorks Stacks supports five lifecycle events: setup, configuration, deploy, undeploy, and shutdown. For each layer, AWS OpsWorks Stacks runs a set of standard recipes for each event. In addition, you can provide custom recipes for any or all layers and events. AWS OpsWorks Stacks runs custom event recipes after the standard recipes. LayerCustomRecipes specifies the custom recipes for a particular layer to be run in response to each of the five events.

To specify a recipe, use the cookbook's directory name in the repository followed by two colons and the recipe name, which is the recipe's file name without the .rb extension. For example: phpapp2::dbsetup specifies the dbsetup.rb recipe in the repository's phpapp2 folder.

Returns:



178
179
180
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 178

def default_recipes
  data[:default_recipes]
end

#default_security_group_namesArray<String>

An array containing the layer's security group names.

Returns:

  • (Array<String>)


115
116
117
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 115

def default_security_group_names
  data[:default_security_group_names]
end

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


layer.delete()

Parameters:

  • options (Hash) (defaults to: {})

    ({})

Returns:

  • (EmptyStructure)


361
362
363
364
365
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 361

def delete(options = {})
  options = options.merge(layer_id: @id)
  resp = @client.delete_layer(options)
  resp.data
end

#enable_auto_healingBoolean

Whether auto healing is disabled for the layer.

Returns:

  • (Boolean)


134
135
136
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 134

def enable_auto_healing
  data[:enable_auto_healing]
end

#idString

Returns:

  • (String)


29
30
31
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 29

def id
  @id
end

#install_updates_on_bootBoolean

Whether to install operating system and package updates when the instance boots. The default value is true. If this value is set to false, you must then update your instances manually by using CreateDeployment to run the update_dependencies stack command or manually running yum (Amazon Linux) or apt-get (Ubuntu) on the instances.

We strongly recommend using the default value of true, to ensure that your instances have the latest security updates.

Returns:

  • (Boolean)


207
208
209
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 207

def install_updates_on_boot
  data[:install_updates_on_boot]
end

#layer_idString

The layer ID.

Returns:

  • (String)


47
48
49
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 47

def layer_id
  data[:layer_id]
end

#lifecycle_event_configurationTypes::LifecycleEventConfiguration

A LifeCycleEventConfiguration object that specifies the Shutdown event configuration.



220
221
222
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 220

def lifecycle_event_configuration
  data[:lifecycle_event_configuration]
end

#loadself Also known as: reload

Loads, or reloads #data for the current Aws::OpsWorks::Layer. Returns self making it possible to chain methods.

layer.reload.data

Returns:

  • (self)


237
238
239
240
241
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 237

def load
  resp = @client.describe_layers(layer_ids: [@id])
  @data = resp.layers[0]
  self
end

#nameString

The layer name.

Returns:

  • (String)


59
60
61
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 59

def name
  data[:name]
end

#packagesArray<String>

An array of Package objects that describe the layer's packages.

Returns:

  • (Array<String>)


121
122
123
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 121

def packages
  data[:packages]
end

#shortnameString

The layer short name.

Returns:

  • (String)


65
66
67
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 65

def shortname
  data[:shortname]
end

#stackStack?

Returns:



370
371
372
373
374
375
376
377
378
379
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 370

def stack
  if data[:stack_id]
    Stack.new(
      id: data[:stack_id],
      client: @client
    )
  else
    nil
  end
end

#stack_idString

The layer stack ID.

Returns:

  • (String)


41
42
43
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 41

def stack_id
  data[:stack_id]
end

#typeString

The layer type.

Returns:

  • (String)


53
54
55
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 53

def type
  data[:type]
end

#use_ebs_optimized_instancesBoolean

Whether the layer uses Amazon EBS-optimized instances.

Returns:

  • (Boolean)


213
214
215
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 213

def use_ebs_optimized_instances
  data[:use_ebs_optimized_instances]
end

#volume_configurationsArray<Types::VolumeConfiguration>

A VolumeConfigurations object that describes the layer's Amazon EBS volumes.

Returns:



128
129
130
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 128

def volume_configurations
  data[:volume_configurations]
end

#wait_until(options = {}, &block) ⇒ Resource

Deprecated.

Use [Aws::OpsWorks::Client] #wait_until instead

Note:

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(options) {|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

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :max_attempts (Integer) — default: 10

    Maximum number of

  • :delay (Integer) — default: 10

    Delay between each

  • :before_attempt (Proc) — default: nil

    Callback

  • :before_wait (Proc) — default: nil

    Callback

Returns:

  • (Resource)

    if the waiter was successful

Raises:

  • (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.

  • (Aws::Waiters::Errors::UnexpectedError)

    Raised when an error is encountered while polling for a resource that is not expected.

  • (NotImplementedError)

    Raised when the resource does not



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'gems/aws-sdk-opsworks/lib/aws-sdk-opsworks/layer.rb', line 337

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