Class: Forger::Create
- Includes:
- AwsServices, ErrorMessages
- Defined in:
- lib/forger/create.rb,
lib/forger/create/info.rb,
lib/forger/create/params.rb,
lib/forger/create/waiter.rb,
lib/forger/create/error_messages.rb
Defined Under Namespace
Modules: ErrorMessages Classes: Info, Params, Waiter
Constant Summary
Constants inherited from Base
Base::BUILD_ROOT, Base::SCRIPTS_INFO_PATH
Instance Method Summary collapse
-
#params ⇒ Object
params are main derived from profile files.
- #run ⇒ Object
- #run_instances(params) ⇒ Object
- #sync_scripts_to_s3 ⇒ Object
Methods included from ErrorMessages
#handle_ec2_service_error!, #invalid_group_not_found, #invalid_parameter_combination, #invalid_subnet_id_not_found, #map_exception_to_method, #print_error_message
Methods included from AwsServices
Methods inherited from Base
#derandomize, #initialize, #randomize
Constructor Details
This class inherits a constructor from Forger::Base
Instance Method Details
#params ⇒ Object
params are main derived from profile files
46 47 48 |
# File 'lib/forger/create.rb', line 46 def params @params ||= Params.new(@options).generate end |
#run ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/forger/create.rb', line 9 def run Profile.new(@options).check! Hook.run(:before_run_instances, @options) sync_scripts_to_s3 puts "Creating EC2 instance #{@name.color(:green)}" info = Info.new(@options, params) info.ec2_params if @options[:noop] puts "NOOP mode enabled. EC2 instance not created." return end resp = run_instances(params) instance_id = resp.instances.first.instance_id info.spot(instance_id) puts "EC2 instance with profile #{@name.color(:green)} created: #{instance_id} 🎉" puts "Visit https://console.aws.amazon.com/ec2/home to check on the status" info.cloudwatch(instance_id) Waiter.new(@options.merge(instance_id: instance_id)).wait end |
#run_instances(params) ⇒ Object
34 35 36 37 38 |
# File 'lib/forger/create.rb', line 34 def run_instances(params) ec2.run_instances(params) rescue Aws::EC2::Errors::ServiceError => e handle_ec2_service_error!(e) end |