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: {})


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

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

Instance Attribute Details

#stackStack (readonly)

Returns:



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

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.



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

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