lib/roark/cli/create.rb in roark-0.1.0 vs lib/roark/cli/create.rb in roark-0.2.0
- old
+ new
@@ -3,11 +3,14 @@
class Create
include Shared
def initialize
- @options = { :account_ids => [], :parameters => {}, :region => 'us-east-1' }
+ @options = { :account_ids => [],
+ :parameters => {},
+ :region => 'us-east-1',
+ :tags => {} }
@logger = Roark.logger
end
def create
option_parser.parse!
@@ -25,10 +28,11 @@
ami = Roark::Ami.new :aws => aws, :name => @options[:name]
ami_create_workflow = Roark::AmiCreateWorkflow.new :account_ids => @options[:account_ids],
:ami => ami,
+ :tags => @options[:tags],
:template => template,
:parameters => @options[:parameters]
response = ami_create_workflow.execute
unless response.success?
@@ -45,10 +49,14 @@
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("-c", "--cloud_formation_template [CLOUD_FORMATION_TEMPLATE]", "Path to Cloud Formation template") do |o|
+ @options[:template] = o
+ end
+
opts.on("-n", "--name [NAME]", "Name of AMI") do |o|
@options[:name] = o
end
opts.on("-p", "--parameters [PARAMETERS]", "Parameter name and it's value separated by '=' to pass to Cloud Formation. Can be specified multiple times.") do |o|
@@ -58,11 +66,12 @@
opts.on("-r", "--region [REGION]", "Region to build AMI") do |o|
@options[:region] = o
end
- opts.on("-t", "--template [TEMPLATE]", "Path to Cloud Formation template") do |o|
- @options[:template] = o
+ opts.on("-t", "--tag [TAG]", "AMI tag name and it's value separated by '='. Can be specified multiple times.") do |o|
+ data = o.split('=')
+ @options[:tags].merge!({ data.first => data[1] })
end
opts.on("--aws-access-key [KEY]", "AWS Access Key") do |o|
@options[:aws_access_key] = o
end