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

Class: AWS::CloudFormation::Stack

Inherits:
AWS::Core::Resource
  • Object
show all
Defined in:
lib/aws/cloud_formation/stack.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#capabilitiesArray<String> (readonly)

The capabilities allowed in the stack.

Returns:

  • (Array<String>)

    the current value of capabilities



50
51
52
# File 'lib/aws/cloud_formation/stack.rb', line 50

def capabilities
  @capabilities
end

#creation_timeTime (readonly)

The time the stack was created.

Returns:

  • (Time)

    the current value of creation_time



50
51
52
# File 'lib/aws/cloud_formation/stack.rb', line 50

def creation_time
  @creation_time
end

#descriptionString (readonly)

User defined description associated with the stack.

Returns:

  • (String)

    the current value of description



50
51
52
# File 'lib/aws/cloud_formation/stack.rb', line 50

def description
  @description
end

#disable_rollbackBoolean (readonly) Also known as: disable_rollback?

Specifies if the stack is rolled back due to stack creation errors.

Returns:

  • (Boolean)

    the current value of disable_rollback



50
51
52
# File 'lib/aws/cloud_formation/stack.rb', line 50

def disable_rollback
  @disable_rollback
end

#last_updated_timeTime? (readonly)

The time the stack was last updated.

Returns:

  • (Time, nil)

    the current value of last_updated_time



50
51
52
# File 'lib/aws/cloud_formation/stack.rb', line 50

def last_updated_time
  @last_updated_time
end

#nameString (readonly)

Returns the stack name.

Returns:

  • (String)

    Returns the stack name.



61
62
63
# File 'lib/aws/cloud_formation/stack.rb', line 61

def name
  @name
end

#notification_arnsArray<String> (readonly)

SNS topic ARNs to which stack related events are published.

Returns:

  • (Array<String>)

    the current value of notification_arns



50
51
52
# File 'lib/aws/cloud_formation/stack.rb', line 50

def notification_arns
  @notification_arns
end

#parametersHash (readonly)

Returns a hash of stack parameters.

Returns:

  • (Hash)

    the current value of parameters



50
51
52
# File 'lib/aws/cloud_formation/stack.rb', line 50

def parameters
  @parameters
end

#stack_idString (readonly)

Unique stack identifier.

Returns:

  • (String)

    the current value of stack_id



50
51
52
# File 'lib/aws/cloud_formation/stack.rb', line 50

def stack_id
  @stack_id
end

#statusString (readonly)

The status of the stack.

Returns:

  • (String)

    the current value of status



50
51
52
# File 'lib/aws/cloud_formation/stack.rb', line 50

def status
  @status
end

#status_reasonString (readonly)

Success/Failure message associated with the status.

Returns:

  • (String)

    the current value of status_reason



50
51
52
# File 'lib/aws/cloud_formation/stack.rb', line 50

def status_reason
  @status_reason
end

#templateString (readonly) Also known as: template_body

Returns the stack's template as a JSON string.

Returns:

  • (String)

    the current value of template



50
51
52
# File 'lib/aws/cloud_formation/stack.rb', line 50

def template
  @template
end

#timeoutInteger (readonly) Also known as: timeout_in_minutes

The number of minutes within the stack creation should complete.

Returns:

  • (Integer)

    the current value of timeout



50
51
52
# File 'lib/aws/cloud_formation/stack.rb', line 50

def timeout
  @timeout
end

Instance Method Details

#deletenil

Deletes the current stack.

Returns:

  • (nil)


235
236
237
238
# File 'lib/aws/cloud_formation/stack.rb', line 235

def delete
  client.delete_stack(:stack_name => name)
  nil
end

#estimate_template_costString

Returns a URL to the AWS Simple Monthly Calculator with a query string that describes the resources required to run the template.

Returns:

  • (String)

    Returns a URL to the AWS Simple Monthly Calculator with a query string that describes the resources required to run the template.



228
229
230
231
# File 'lib/aws/cloud_formation/stack.rb', line 228

def estimate_template_cost
  cloud_formation = CloudFormation.new(:config => config)
  cloud_formation.estimate_template_cost(template, parameters)
end

#eventsStackEventCollection

Returns a collection that represents all events for this stack.

Returns:



148
149
150
# File 'lib/aws/cloud_formation/stack.rb', line 148

def events
  StackEventCollection.new(self)
end

#exists?Boolean

Returns:

  • (Boolean)


241
242
243
244
245
246
247
248
# File 'lib/aws/cloud_formation/stack.rb', line 241

def exists?
  begin
    client.describe_stacks(resource_options)
    true
  rescue Errors::ValidationError
    false
  end
end

#outputsArray<StackOutput>

Returns:



139
140
141
142
143
144
# File 'lib/aws/cloud_formation/stack.rb', line 139

def outputs
  output_details.collect do |o|
    key, value, desc = o.values_at(:output_key, :output_value, :description)
    StackOutput.new(self, key, value, desc)
  end
end

#resource_summariesStackResourceSummaryCollection

Returns a stack resource summary collection, that when enumerated yields summary hashes. Each hash has the following keys:

  • :last_updated_timestamp
  • :logical_resource_id
  • :physical_resource_id
  • :resource_status
  • :resource_status_reason
  • :resource_type


182
183
184
# File 'lib/aws/cloud_formation/stack.rb', line 182

def resource_summaries
  StackResourceSummaryCollection.new(self)
end

#resourcesStackResourceCollection

Returns a stack resource collection that enumerates all resources for this stack.

stack.resources.each do |resource|
  puts "#{resource.resource_type}: #{resource.physical_resource_id}"
end

If you want a specific resource and you know its logical resource id, you can use this collection to return a reference to it.

resource = stack.resources['logical-resource-id']


166
167
168
# File 'lib/aws/cloud_formation/stack.rb', line 166

def resources
  StackResourceCollection.new(self)
end

#update(options = {}) ⇒ nil

Parameters:

  • options (Hash) (defaults to: {})
  • options[Array<String>] (Hash)

    a customizable set of options

Options Hash (options):

  • :template (String, URI, S3::S3Object, Object)

    A new stack template. This may be provided in a number of formats including:

    • a String, containing the template as a JSON document.
    • a URL String pointing to the document in S3.
    • a URI object pointing to the document in S3.
    • an S3::S3Object which contains the template.
    • an Object which responds to #to_json and returns the template.
  • :parameters (Hash)

    A hash that specifies the input parameters of the new stack.

Returns:

  • (nil)


215
216
217
218
219
220
221
222
223
224
225
# File 'lib/aws/cloud_formation/stack.rb', line 215

def update options = {}
  client_opts = options.dup

  apply_stack_name(name, client_opts)
  apply_template(client_opts)
  apply_parameters(client_opts)

  client.update_stack(client_opts)

  nil
end