Sha256: ae1cebf928054bff12e96bd833cd6477013c32db990678c411f7a48bc68a68ee

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

require 'trollop'

module SimplePerf
  module CLI
    class CreateBucket
      def execute
        opts = Trollop::options do
          version SimplePerf::VERSION
          banner <<-EOS

Creates CloudFormation stack for s3 bucket.

Usage:
      simple_perf create_bucket -e ENVIRONMENT -n STACK_NAME
EOS
          opt :help, "Display Help"
          opt :environment, "Set the target environment", :type => :string
          opt :name, "Stack name to manage", :type => :string
        end
        Trollop::die :environment, "is required but not specified" unless opts[:environment]
        Trollop::die :name, "is required but not specified" unless opts[:name]

        gem_root = File.expand_path '../..', __FILE__

        config = Config.new.environment opts[:environment]

        command = 'simple_deploy create' +
            ' -e ' + opts[:environment] +
            ' -n ' + opts[:name] +
            ' -t '+ gem_root + '/cloud_formation_templates/s3_bucket.json'

        `#{command}`

        command = 'simple_deploy outputs' +
            ' -e ' + opts[:environment] +
            ' -n ' + opts[:name]

        (0..5).each do |i|
          puts "Getting s3 bucket name..."
          sleep 10
          output = `#{command}`
          if output.length > 0
            puts output
            break
          end
        end

      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple_perf-0.0.5 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.4 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.3 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.2 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.1 lib/simple_perf/cli/create_bucket.rb