Sha256: 5130060a0ee2500293198b5d5ea49ab56b7311ba2b626a5fcb8320f2ffe0131d

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'fog'

module Stackster
  class AWS
    class CloudFormation

      def initialize(args)
        c = args[:config]
        @connect = Fog::AWS::CloudFormation.new :aws_access_key_id => c.access_key,
                                                :aws_secret_access_key => c.secret_key,
                                                :region => c.region
      end

      def create(args)
        data = { 'Capabilities' => ['CAPABILITY_IAM'],
                 'TemplateBody' => args[:template] }.merge( { 'Parameters' => args[:parameters] } )
        @connect.create_stack(args[:name], data)
      end

      def destroy(name)
        @connect.delete_stack name
      end

      def describe_stack(name)
        @connect.describe_stacks('StackName' => name).body['Stacks']
      end

      def stack_resources(name)
        @connect.describe_stack_resources('StackName' => name).body['StackResources']
      end

      def stack_events(name)
        @connect.describe_stack_events(name).body['StackEvents']
      end

      def stack_status(name)
        describe_stack(name).first['StackStatus']
      end

      def stack_outputs(name)
        describe_stack(name).last['Outputs']
      end

      def template(name)
        @connect.get_template(name).body['TemplateBody']
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stackster-0.0.3 lib/stackster/aws/cloud_formation.rb