Class: Roark::CLI::Create
- Inherits:
-
Object
- Object
- Roark::CLI::Create
- Includes:
- Shared
- Defined in:
- lib/roark/cli/create.rb
Instance Method Summary collapse
- #command_summary ⇒ Object
- #create ⇒ Object
-
#initialize ⇒ Create
constructor
A new instance of Create.
- #option_parser ⇒ Object
Methods included from Shared
#aws, #command_name, #help, #validate_account_ids_format, #validate_required_options
Constructor Details
Instance Method Details
#command_summary ⇒ Object
86 87 88 |
# File 'lib/roark/cli/create.rb', line 86 def command_summary 'Creates an AMI' end |
#create ⇒ Object
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 40 41 42 43 44 |
# File 'lib/roark/cli/create.rb', line 15 def create option_parser.parse! [:name, :cloud_formation_template] validate_account_ids_format unless File.exists? @options[:cloud_formation_template] @logger.error "Template #{@options[:cloud_formation_template]} does not exist." exit 1 end cloud_formation_template = File.read @options[:cloud_formation_template] 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 => cloud_formation_template, :parameters => @options[:parameters] response = ami_create_workflow.execute unless response.success? @logger.error response. exit 1 end @logger.info response. end |
#option_parser ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/roark/cli/create.rb', line 46 def option_parser OptionParser.new do |opts| opts. = "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("-c", "--cloud_formation_template [CLOUD_FORMATION_TEMPLATE]", "Path to Cloud Formation template") do |o| @options[:cloud_formation_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| data = o.split('=') @options[:parameters].merge!({ data.first => data[1] }) end opts.on("-r", "--region [REGION]", "Region to build AMI") do |o| @options[:region] = o end 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 opts.on("--aws-secret-key [KEY]", "AWS Secret Key") do |o| @options[:aws_secret_key] = o end end end |