Sha256: 3b97720bc377743061dd125f8654aafc9b2cb4fec282588c58c3c85b7e32d7b4

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

require 'fog'

module Stackster
  class AWS
    class CloudFormation

      def initialize(environment)
        c = Config.environment environment
        @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)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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