Class: Awsom::Cli::Resources
- Inherits:
-
Object
- Object
- Awsom::Cli::Resources
- Defined in:
- lib/awsom/cli/resources.rb
Instance Method Summary collapse
- #init_aws(config) ⇒ Object
-
#initialize(argv) ⇒ Resources
constructor
A new instance of Resources.
- #lock ⇒ Object
- #opts ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Resources
Returns a new instance of Resources.
8 9 10 |
# File 'lib/awsom/cli/resources.rb', line 8 def initialize(argv) @argv = argv end |
Instance Method Details
#init_aws(config) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/awsom/cli/resources.rb', line 27 def init_aws(config) require 'aws-sdk-core' if config.key?(:aws_key) && config.key?(:aws_secret) credentials = Aws::Credentials.new(config.fetch(:aws_key), config.fetch(:aws_secret)) Aws.config[:credentials] = credentials end Aws.config[:region] = config.fetch(:region) require_relative '../ec2' end |
#lock ⇒ Object
37 38 39 |
# File 'lib/awsom/cli/resources.rb', line 37 def lock @lock ||= ::Awsom::Lock.new end |
#opts ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/awsom/cli/resources.rb', line 41 def opts OptionParser.new do |opts| opts. = "Usage: awsom create [options] [target]" opts.on("-f", "--file FILE", "Specify hosts file") do |f| salt.hosts_file = f end opts.on("-h", "--help", "Help") do puts opts exit end end end |
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/awsom/cli/resources.rb', line 12 def run lock.acquire opts.parse!(@argv) config = Config.new("config.rb").config init_aws(config) vpc_id = config.fetch :vpc_id region = config.fetch :region require 'awsom/application' app = Application.new(vpc_id: vpc_id, region: region) app.run(@argv) end |