Parent

Files

Class/Module Index [+]

Quicksearch

Fog::AWS::CloudFormation::Real

Public Class Methods

new(options={}) click to toggle source

Initialize connection to CloudFormation

Notes

options parameter must include values for :aws_access_key_id and :aws_secret_access_key in order to create a connection

Examples

cf = CloudFormation.new(
 :aws_access_key_id => your_aws_access_key_id,
 :aws_secret_access_key => your_aws_secret_access_key
)

Parameters

  • options<~Hash> - config arguments for connection. Defaults to {}.

Returns

# File lib/fog/aws/cloud_formation.rb, line 47
def initialize(options={})
  require 'fog/core/parser'
  require 'multi_json'

  @aws_access_key_id      = options[:aws_access_key_id]
  @aws_secret_access_key  = options[:aws_secret_access_key]
  @hmac       = Fog::HMAC.new('sha256', @aws_secret_access_key)

  @connection_options = options[:connection_options] || {}
  options[:region] ||= 'us-east-1'
  @host = options[:host] || case options[:region]
  when 'ap-northeast-1'
    'cloudformation.ap-northeast-1.amazonaws.com'
  when 'ap-southeast-1'
    'cloudformation.ap-southeast-1.amazonaws.com'
  when 'eu-west-1'
    'cloudformation.eu-west-1.amazonaws.com'
  when 'us-east-1'
    'cloudformation.us-east-1.amazonaws.com'
  when 'us-west-1'
    'cloudformation.us-west-1.amazonaws.com'
  when 'us-west-2'
    'cloudformation.us-west-2.amazonaws.com'
  when 'sa-east-1'
    'cloudformation.sa-east-1.amazonaws.com'
  else
    raise ArgumentError, "Unknown region: #{options[:region].inspect}"
  end
  @path       = options[:path]        || '/'
  @persistent = options[:persistent]  || false
  @port       = options[:port]        || 443
  @scheme     = options[:scheme]      || 'https'
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end

Public Instance Methods

create_stack(stack_name, options = {}) click to toggle source

Create a stack

Parameters

  • stack_name<~String>: name of the stack to create

  • options<~Hash>:

    • TemplateBody<~String>: structure containing the template body

    or (one of the two Template parameters is required)

    • TemplateURL<~String>: URL of file containing the template body

    • DisableRollback<~Boolean>: Controls rollback on stack creation failure, defaults to false

    • NotificationARNs<~Array>: List of SNS topics to publish events to

    • Parameters<~Hash>: Hash of providers to supply to template

    • TimeoutInMinutes<~Integer>: Minutes to wait before status is set to CREATE_FAILED

    • Capabilities<~Array>: List of capabilties the stack is granted. Currently CAPABILITY_IAM for allowing the creation of IAM resources

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'StackId'<~String> - Id of the new stack

See Also

docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_CreateStack.html

# File lib/fog/aws/requests/cloud_formation/create_stack.rb, line 31
def create_stack(stack_name, options = {})
  params = {
    'StackName' => stack_name,
  }

  if options['DisableRollback']
    params['DisableRollback'] = options['DisableRollback']
  end

  if options['NotificationARNs']
    params.merge!(Fog::AWS.indexed_param("NotificationARNs.member", [*options['NotificationARNs']]))
  end

  if options['Parameters']
    options['Parameters'].keys.each_with_index do |key, index|
      index += 1 # params are 1-indexed
      params.merge!({
        "Parameters.member.#{index}.ParameterKey"   => key,
        "Parameters.member.#{index}.ParameterValue" => options['Parameters'][key]
      })
    end
  end

  if options['TemplateBody']
    params['TemplateBody'] = options['TemplateBody']
  elsif options['TemplateURL']
    params['TemplateURL'] = options['TemplateURL']
  end

  if options['TimeoutInMinutes']
    params['TimeoutInMinutes'] = options['TimeoutInMinutes']
  end
  
  if options['Capabilities']
    params.merge!(Fog::AWS.indexed_param("Capabilities.member", [*options['Capabilities']]))
  end

  request({
    'Action'    => 'CreateStack',
    :parser     => Fog::Parsers::AWS::CloudFormation::CreateStack.new
  }.merge!(params))
end
delete_stack(stack_name) click to toggle source

Delete a stack

Parameters

  • stack_name<~String>: name of the stack to create

Returns

  • response<~Excon::Response>:

See Also

docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DeleteStack.html

# File lib/fog/aws/requests/cloud_formation/delete_stack.rb, line 19
def delete_stack(stack_name)
  request(
    'Action'    => 'DeleteStack',
    'StackName' => stack_name,
    :parser     => Fog::Parsers::AWS::CloudFormation::Basic.new
  )
end
describe_stack_events(stack_name, options = {}) click to toggle source

Describe stack events

Parameters

  • stack_name<~String>: stack name to return events for

  • options<~Hash>:

    • NextToken<~String>: identifies the start of the next list of events, if there is one

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'StackEvents'<~Array> - Matching resources

        • event<~Hash>:

          • 'EventId'<~String> -

          • 'StackId'<~String> -

          • 'StackName'<~String> -

          • 'LogicalResourceId'<~String> -

          • 'PhysicalResourceId'<~String> -

          • 'ResourceType'<~String> -

          • 'Timestamp'<~Time> -

          • 'ResourceStatus'<~String> -

          • 'ResourceStatusReason'<~String> -

See Also

docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DescribeStackEvents.html

# File lib/fog/aws/requests/cloud_formation/describe_stack_events.rb, line 33
def describe_stack_events(stack_name, options = {})
  request({
    'Action'    => 'DescribeStackEvents',
    'StackName' => stack_name,
    :parser     => Fog::Parsers::AWS::CloudFormation::DescribeStackEvents.new
  }.merge!(options))
end
describe_stack_resources(options = {}) click to toggle source

Describe stack resources

Parameters

  • options<~Hash>:

    • 'PhysicalResourceId'<~String>: name or unique identifier that corresponds to a physical instance ID

    or (one of PhysicalResourceId and StackName is required)

    • 'StackName'<~String>: only return events related to this stack name

    • 'LogicalResourceId'<~String>: logical name of the resource as specified in the template

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'StackResources'<~Array> - Matching resources

        • resource<~Hash>:

          • 'StackId'<~String> -

          • 'StackName'<~String> -

          • 'LogicalResourceId'<~String> -

          • 'PhysicalResourceId'<~String> -

          • 'ResourceType'<~String> -

          • 'Timestamp'<~Time> -

          • 'ResourceStatus'<~String> -

See Also

docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DescribeStackResources.html

# File lib/fog/aws/requests/cloud_formation/describe_stack_resources.rb, line 33
def describe_stack_resources(options = {})
  request({
    'Action'    => 'DescribeStackResources',
    :parser     => Fog::Parsers::AWS::CloudFormation::DescribeStackResources.new
  }.merge!(options))
end
describe_stacks(options = {}) click to toggle source

Describe stacks

Parameters

  • options<~Hash>:

    • 'StackName'<~String>: name of the stack to describe

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'Stacks'<~Array> - Matching stacks

        • stack<~Hash>:

          • 'StackName'<~String> -

          • 'StackId'<~String> -

          • 'CreationTime'<~String> -

          • 'StackStatus'<~String> -

          • 'DisableRollback'<~String> -

          • 'Outputs'<~Array> -

            • output<~Hash>:

              • 'OutputKey'<~String> -

              • 'OutputValue'<~String> -

See Also

docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_DescribeStacks.html

# File lib/fog/aws/requests/cloud_formation/describe_stacks.rb, line 32
def describe_stacks(options = {})
  request({
    'Action'    => 'DescribeStacks',
    :parser     => Fog::Parsers::AWS::CloudFormation::DescribeStacks.new
  }.merge!(options))
end
get_template(stack_name) click to toggle source

Describe stacks

Parameters

  • stack_name<~String> - stack name to get template from

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'TemplateBody'<~String> - structure containing the template body (json)

See Also

docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_GetTemplate.html

# File lib/fog/aws/requests/cloud_formation/get_template.rb, line 21
def get_template(stack_name)
  request(
    'Action'    => 'GetTemplate',
    'StackName' => stack_name,
    :parser     => Fog::Parsers::AWS::CloudFormation::GetTemplate.new
  )
end
reload() click to toggle source
# File lib/fog/aws/cloud_formation.rb, line 82
def reload
  @connection.reset
end
update_stack(stack_name, options = {}) click to toggle source

Update a stack

Parameters

  • stack_name<~String>: name of the stack to update

  • options<~Hash>:

    • TemplateBody<~String>: structure containing the template body

    or (one of the two Template parameters is required)

    • TemplateURL<~String>: URL of file containing the template body

    • Parameters<~Hash>: Hash of providers to supply to template

    • Capabilities<~Array>: List of capabilties the stack is granted. Currently CAPABILITY_IAM for allowing the creation of IAM resources

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'StackId'<~String> - Id of the stack being updated

See Also

docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_UpdateStack.html

# File lib/fog/aws/requests/cloud_formation/update_stack.rb, line 28
def update_stack(stack_name, options = {})
  params = {
    'StackName' => stack_name,
  }

  if options['Parameters']
    options['Parameters'].keys.each_with_index do |key, index|
      index += 1 # params are 1-indexed
      params.merge!({
        "Parameters.member.#{index}.ParameterKey"   => key,
        "Parameters.member.#{index}.ParameterValue" => options['Parameters'][key]
      })
    end
  end

  if options['TemplateBody']
    params['TemplateBody'] = options['TemplateBody']
  elsif options['TemplateURL']
    params['TemplateURL'] = options['TemplateURL']
  end

  if options['Capabilities']
    params.merge!(Fog::AWS.indexed_param("Capabilities.member", [*options['Capabilities']]))
  end

  request({
    'Action'    => 'UpdateStack',
    :parser     => Fog::Parsers::AWS::CloudFormation::UpdateStack.new
  }.merge!(params))
end
validate_template(options = {}) click to toggle source

Describe stacks

Parameters

  • options<~Hash>:

    • 'TemplateBody'<~String> - template structure

    • 'TemplateURL'<~String> - template url

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

      • 'Description'<~String> - description found within the template

      • 'Parameters'<~String> - list of template parameter structures

See Also

docs.amazonwebservices.com/AWSCloudFormation/latest/APIReference/API_ValidateTemplate.html

# File lib/fog/aws/requests/cloud_formation/validate_template.rb, line 24
def validate_template(options = {})
  request({
    'Action'    => 'ValidateTemplate',
    :parser     => Fog::Parsers::AWS::CloudFormation::ValidateTemplate.new
  }.merge!(options))
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.