Sha256: 411ba99f22dd4e3561c7ac3d367d984478973137317092598d8c9b882abf4821

Contents?: true

Size: 1.44 KB

Versions: 12

Compression:

Stored size: 1.44 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 -p PROJECT_NAME

EOS
          opt :help, "Display Help"
          opt :environment, "Set the target environment", :type => :string
          opt :project, "Project name to manage", :type => :string
        end
        Trollop::die :environment, "is required but not specified" unless opts[:environment]
        Trollop::die :project, "is required but not specified" unless opts[:project]

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

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

        command = 'simple_deploy create' +
            ' -e ' + opts[:environment] +
            ' -n ' + 'simple-perf-' + opts[:project] + '-s3-' + config['region'] +
            ' -t '+ gem_root + '/cloud_formation_templates/s3_bucket.json'

        `#{command}`

        command = 'simple_deploy outputs' +
            ' -e ' + opts[:environment] +
            ' -n ' + 'simple-perf-' + opts[:project] + '-s3-' + config['region']

        (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

12 entries across 12 versions & 1 rubygems

Version Path
simple_perf-0.0.18 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.17 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.15 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.14 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.13 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.12 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.11 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.10 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.9 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.8 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.7 lib/simple_perf/cli/create_bucket.rb
simple_perf-0.0.6 lib/simple_perf/cli/create_bucket.rb