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_timeObject (readonly)

returned by DescribeStacks



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

#templateObject (readonly) Also known as: template_body

returned by GetTemplate



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)


224
225
226
227
# File 'lib/aws/cloud_formation/stack.rb', line 224

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

#describe_stacksObject

attribute providers



113
114
115
116
117
118
# File 'lib/aws/cloud_formation/stack.rb', line 113

provider(:describe_stacks) do |provider|
  provider.find do |resp|
    resp.data[:stacks].find{|stack| stack[:stack_name] == name }
  end
  provider.provides *describe_attributes.keys
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.



217
218
219
220
# File 'lib/aws/cloud_formation/stack.rb', line 217

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:



137
138
139
# File 'lib/aws/cloud_formation/stack.rb', line 137

def events
  StackEventCollection.new(self)
end

#exists?Boolean

Returns:

  • (Boolean)


230
231
232
233
234
235
236
237
# File 'lib/aws/cloud_formation/stack.rb', line 230

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

#outputsArray<StackOutput>

Returns:



128
129
130
131
132
133
# File 'lib/aws/cloud_formation/stack.rb', line 128

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



171
172
173
# File 'lib/aws/cloud_formation/stack.rb', line 171

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


155
156
157
# File 'lib/aws/cloud_formation/stack.rb', line 155

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)


204
205
206
207
208
209
210
211
212
213
214
# File 'lib/aws/cloud_formation/stack.rb', line 204

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