class AWS::CloudFormation::Stack

@attr_reader [String] template Returns the stack’s template as a JSON

string.

@attr_reader [Time] creation_time The time the stack was created.

@attr_reader [Time,nil] last_updated_time The time the stack was

last updated.

@attr_reader [String] stack_id Unique stack identifier.

@attr_reader [String] status The status of the stack.

@attr_reader [String] status_reason Success/Failure message

associated with the `status`.

@attr_reader [Array<String>] capabilities The capabilities

allowed in the stack.

@attr_reader [String] description User defined description

associated with the stack.

@attr_reader [Boolean] disable_rollback Specifies if the stack

is rolled back due to stack creation errors.

@attr_reader [Array<String>] notification_arns

SNS topic ARNs to which stack related events are published.

@attr_reader [Hash] parameters Returns a hash of stack parameters.

@attr_reader [Integer] timeout

The number of minutes within the stack creation should complete.

Attributes

name[R]

@return [String] Returns the stack name.

Public Class Methods

new(name, options = {}) click to toggle source

@api private

Calls superclass method
# File lib/aws/cloud_formation/stack.rb, line 55
def initialize name, options = {}
  @name = name
  super
end

Public Instance Methods

delete() click to toggle source

Deletes the current stack. @return [nil]

# File lib/aws/cloud_formation/stack.rb, line 235
def delete
  client.delete_stack(:stack_name => name)
  nil
end
estimate_template_cost() click to toggle source

@return (see CloudFormation#estimate_template_cost)

# 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
events() click to toggle source

@return [StackEventCollection] Returns a collection that represents

all events for this stack.
# File lib/aws/cloud_formation/stack.rb, line 148
def events
  StackEventCollection.new(self)
end
exists?() click to toggle source

@return [Boolean]

# File lib/aws/cloud_formation/stack.rb, line 241
def exists?
  begin
    client.describe_stacks(resource_options)
    true
  rescue Errors::ValidationError
    false
  end
end
outputs() click to toggle source

@return [Array<StackOutput>]

# 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_summaries() click to toggle source

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`

@return [StackResourceSummaryCollection]

# File lib/aws/cloud_formation/stack.rb, line 182
def resource_summaries
  StackResourceSummaryCollection.new(self)
end
resources() click to toggle source

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']

@return [StackResourceCollection]

# File lib/aws/cloud_formation/stack.rb, line 166
def resources
  StackResourceCollection.new(self)
end
update(options = {}) click to toggle source

@param [Hash] options

@option options [String,URI,S3::S3Object,Object] :template

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.

@option options [Hash] :parameters A hash that specifies the

input parameters of the new stack.

@option

# 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

Protected Instance Methods

get_resource(attribute) click to toggle source
# File lib/aws/cloud_formation/stack.rb, line 256
def get_resource attribute
  if attribute.name == :template
    client.get_template(resource_options)
  else
    client.describe_stacks(resource_options)
  end
end
resource_identifiers() click to toggle source
# File lib/aws/cloud_formation/stack.rb, line 252
def resource_identifiers
  [[:stack_name, name]]
end