class AWS::CloudFormation

@return [Client] the low-level CloudFormation client object
@!attribute [r] client
end
# …
stack.resource_summaries.each do |summary|
# enumerate all resources, this collection can not be filtered
resource summaries (hashes).
As an alternative to stack resources, you can enumerate stack
## Stack Resource Summaries
stack_resource = cfm.stack_resource(‘physical-resource-id’)
id, then you can call {CloudFormation#stack_resource}.
If you need a stack resource, but only have its physical resource
puts res.physical_resource_id
res = stack.resources[‘logical-resource-id’]
# getting a resource by its logical id
end
# …
stack.resources.each do |resource|
# enumerating stack resources
logical resource id.
You can enumerate stack resources or request a stack resource by its
## Stack Resources
See {StackEvent} for a complete list of event attributes.
end
puts “#{event.physical_resource_id}: #{event.resource_status}”
stack.events.each do |event|
You can enumerate events for a stack.
## Stack Events<br><br>cfm.stacks.update(:template => new_template)
You can update the template for a {Stack} with the {Stack#update} method:
#=> “{…}”
.template
You can fetch the template body for a stack as a JSON string.
## Template
end
puts summary.to_yaml
cfm.stack_summaries.with_status(:create_failed).each do |summary|
# filtering stack summaries by status
end
# …
cfm.stack_summaries.each do |stack_summary|
# enumerating stack summaries (hashes)
end
# …
cfm.stacks.each do |stack|
# enumerating all stack objects
summary collection by a status.
objects or stack summaries (simple hashes). You can filter the stack
You can enumerate stacks in two ways. You can enumerate {Stack}
## Enumerating Stacks
stack = cfm.stacks[‘stack-name’]

Given a name, you can fetch a {Stack}.
## Getting a Stack
with capabilities and parameters.
See {StackCollection#create} for more information on creating templates
stack = cfm.stacks.create(‘stack-name’, template)
cfm = AWS::CloudFormation.new
TEMPLATE
}
}
}
}
“ImageId”: “ami-41814f28”
“Properties”: {
“Type”: “AWS::EC2::Instance”,
“web”: {
“Resources”: {
“Description”: “A simple template”,
“AWSTemplateFormatVersion” : “2010-09-09”,
{
template = <<-TEMPLATE
You can create a CloudFormation stack with a name and a template.
## Creating a Stack
This is the starting point for working with CloudFormation.
# Stacks
:secret_access_key => ‘YOUR_SECRET_ACCESS_KEY’)
:access_key_id => ‘YOUR_ACCESS_KEY_ID’,
cf = AWS::CloudFormation.new(
Or you can set them directly on the CloudFormation interface:
:secret_access_key => ‘YOUR_SECRET_ACCESS_KEY’)
:access_key_id => ‘YOUR_ACCESS_KEY_ID’,
AWS.config(
AWS.config:
You can setup default credentials for all AWS services via
## Credentials
Provides an expressive, object-oriented interface to AWS CloudFormation.
# AWS::CloudFormation

def estimate_template_cost template, parameters = {}

Returns:
  • (String) - Returns a URL to the AWS Simple Monthly Calculator

Parameters:
  • parameters (Hash) -- A hash that specifies the input
  • () --
def estimate_template_cost template, parameters = {}
  client_opts = {}
  client_opts[:template] = template
  client_opts[:parameters] = parameters
  apply_template(client_opts)
  apply_parameters(client_opts)
  client.estimate_template_cost(client_opts).url
end

def stack_resource *args

Returns:
  • (StackResource) - Returns the stack resource with the

Parameters:
  • logical_resource_id (String) --
  • stack_name (String) --
  • physical_resource_id (String) -- The physical resource id

Overloads:
  • stack_resource(stack_name, logical_resource_id)
  • stack_resource(physical_resource_id)
def stack_resource *args
  client_opts = {}
  if args.size == 1
    client_opts[:physical_resource_id] = args.first
  else
    client_opts[:stack_name] = args[0]
    client_opts[:logical_resource_id] = args[1]
  end
  response = client.describe_stack_resources(client_opts)
  details = response.stack_resources.first
  StackResource.new_from(
    :describe_stack_resource, details,
    Stack.new(details.stack_name, :config => config),
    details.logical_resource_id)
end

def stack_summaries

Returns:
  • (StackSummaryCollection) -
def stack_summaries
  StackSummaryCollection.new(:config => config)
end

def stacks

Returns:
  • (StackCollection) -
def stacks
  StackCollection.new(:config => config)
end

def validate_template template

Returns:
  • (Hash) -
def validate_template template
  begin
    client_opts = {}
    client_opts[:template] = template
    apply_template(client_opts)
    client.validate_template(client_opts).data
  rescue CloudFormation::Errors::ValidationError => e
    results = {}
    results[:code] = e.code
    results[:message] = e.message
    results
  end
end