Class: BOSHLadle::Cli
- Inherits:
-
Object
- Object
- BOSHLadle::Cli
- Defined in:
- lib/bosh_ladle/cli.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize ⇒ Cli
constructor
A new instance of Cli.
- #run(args) ⇒ Object
Constructor Details
#initialize ⇒ Cli
Returns a new instance of Cli.
8 9 10 |
# File 'lib/bosh_ladle/cli.rb', line 8 def initialize @opts = {} end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
41 42 43 |
# File 'lib/bosh_ladle/cli.rb', line 41 def opts @opts end |
Instance Method Details
#run(args) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bosh_ladle/cli.rb', line 12 def run(args) raise ArgumentError.new('Please set AWS_ACCESS_KEY_ID in the environment') if ENV['AWS_ACCESS_KEY_ID'].nil? raise ArgumentError.new('Please set AWS_SECRET_ACCESS_KEY in the environment') if ENV['AWS_SECRET_ACCESS_KEY'].nil? @opts = Trollop::(args) do <<-PROGINFO This script is meant to spin up BOSH lite VMs inside the GoCD VPC on AWS. It requires AWS credentials stored in the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables to use EC2. Furthermore, it uses the most recently created BOSH-lite AMI available on the AWS marketplace to create the VM. Options: PROGINFO opt :instance_type, "AWS instance type to use", :type => :string, :default => 'm3.xlarge' opt :subnet_id, "The subnet ID to put the VM into (e.g. 'subnet-123abc45')", :type => :string, required: true opt :security_group, "The security group to put the VM into", :type => :string, :default => 'bosh', :short => 'g' opt :key_pair, "The key pair to use (must be available in AWS)", :type => :string, :default => 'gocd_bosh_lite' opt :name, "A name passed to the BOSH lite image (e.g. <team-name>)", :type => :string, required: true end ec2 = AWS::EC2.new( :access_key_id => ENV['AWS_ACCESS_KEY_ID'], :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'] ) BOSHLite.spinup(ec2, opts.subnet_id, opts.name, opts.security_group, opts.key_pair, opts.instance_type) 0 end |