Class: AWS::CloudFormation::StackResourceCollection

Inherits:
Object
  • Object
show all
Includes:
AWS::Core::Collection::Simple
Defined in:
lib/aws/cloud_formation/stack_resource_collection.rb

Overview

StackResourceCollection

This collection represents the resources for a single Stack. You can enumerate resources, or request a specific resource by its logical resource id.

Other Ways to Get Resource Details

If you want to get a StackResource by its physical resource id, then you should use #stack_resource.

You can also take a look at AWS::CloudFormation::Stack#resource_summaries for light-weight hashes of stack resource details.

Examples:

Enumerating stack resources


# enumerating all resources for a stack
stack.resources.each do |resource|
  puts resource.resource_type ` " " ` resource.physical_resource_id
end

Getting a stack resource by its logical resource id


resource = stack.resources['web']

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AWS::Core::Collection

#each, #each_batch, #enum, #first, #in_groups_of, #page

Constructor Details

#initialize(stack, options = {}) ⇒ StackResourceCollection

Returns a new instance of StackResourceCollection.

Parameters:

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


48
49
50
51
# File 'lib/aws/cloud_formation/stack_resource_collection.rb', line 48

def initialize stack, options = {}
  @stack = stack
  super
end

Instance Attribute Details

#stackStack (readonly)

Returns:



54
55
56
# File 'lib/aws/cloud_formation/stack_resource_collection.rb', line 54

def stack
  @stack
end

Instance Method Details

#[](logical_resource_id) ⇒ StackResource

Returns a stack resource with the given logical resource id.

Parameters:

  • logical_resource_id (String)

Returns:

  • (StackResource)

    Returns a stack resource with the given logical resource id.



59
60
61
# File 'lib/aws/cloud_formation/stack_resource_collection.rb', line 59

def [] logical_resource_id
  StackResource.new(stack, logical_resource_id)
end