lib/roark/cli/create.rb in roark-0.0.1 vs lib/roark/cli/create.rb in roark-0.1.0
- old
+ new
@@ -3,31 +3,34 @@
class Create
include Shared
def initialize
- @options = { :parameters => {}, :region => 'us-east-1' }
+ @options = { :account_ids => [], :parameters => {}, :region => 'us-east-1' }
@logger = Roark.logger
end
def create
option_parser.parse!
validate_required_options [:name, :template]
+ validate_account_ids_format
+
unless File.exists? @options[:template]
@logger.error "Template #{@options[:template]} does not exist."
exit 1
end
template = File.read @options[:template]
ami = Roark::Ami.new :aws => aws, :name => @options[:name]
- ami_create_workflow = Roark::AmiCreateWorkflow.new :ami => ami,
- :template => template,
- :parameters => @options[:parameters]
+ ami_create_workflow = Roark::AmiCreateWorkflow.new :account_ids => @options[:account_ids],
+ :ami => ami,
+ :template => template,
+ :parameters => @options[:parameters]
response = ami_create_workflow.execute
unless response.success?
@logger.error response.message
exit 1
@@ -37,9 +40,13 @@
end
def option_parser
OptionParser.new do |opts|
opts.banner = "Usage: roark create [options]"
+
+ opts.on("-a", "--account_id [ACCOUNT_ID]", "AWS Account ID to Authorize. Can be specified multiple times.") do |o|
+ @options[:account_ids] << o
+ end
opts.on("-n", "--name [NAME]", "Name of AMI") do |o|
@options[:name] = o
end