Class: Jets::Commands::Deploy
- Inherits:
-
Object
- Object
- Jets::Commands::Deploy
- Defined in:
- lib/jets/commands/deploy.rb
Constant Summary
Constants included from Timing
Instance Method Summary collapse
- #build_code ⇒ Object
- #check_dev_mode ⇒ Object
-
#exit_unless_updateable! ⇒ Object
All CloudFormation states listed here: docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html.
-
#initialize(options) ⇒ Deploy
constructor
A new instance of Deploy.
- #run ⇒ Object
- #ship(stack_options) ⇒ Object
-
#validate_routes! ⇒ Object
Checks that all routes are validate and have corresponding lambda functions.
Methods included from Timing
clear, #record_data, #record_log, report
Methods included from StackInfo
#first_run?, #parent_stack_name, #s3_bucket, #stack_type
Methods included from AwsServices
#cfn, #lambda, #s3, #s3_resource, #stack_exists?, #stack_in_progress?, #sts
Constructor Details
#initialize(options) ⇒ Deploy
Returns a new instance of Deploy.
6 7 8 |
# File 'lib/jets/commands/deploy.rb', line 6 def initialize() @options = end |
Instance Method Details
#build_code ⇒ Object
35 36 37 |
# File 'lib/jets/commands/deploy.rb', line 35 def build_code Jets::Commands::Build.new(@options).build_code end |
#check_dev_mode ⇒ Object
28 29 30 31 32 33 |
# File 'lib/jets/commands/deploy.rb', line 28 def check_dev_mode if File.exist?("#{Jets.root}dev.mode") puts "The dev.mode file exists. Please removed it and run bundle update before you deploy.".colorize(:red) exit 1 end end |
#exit_unless_updateable! ⇒ Object
All CloudFormation states listed here: docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-describing-stacks.html
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/jets/commands/deploy.rb', line 60 def exit_unless_updateable! stack_name = Jets::Naming.parent_stack_name exists = stack_exists?(stack_name) return unless exists # continue because stack could be updating stack = cfn.describe_stacks(stack_name: stack_name).stacks.first status = stack["stack_status"] if status =~ /^ROLLBACK_/ || status =~ /_IN_PROGRESS$/ puts "Parent stack associate with this '#{Jets.config.project_name}' project not in a updateable state.".colorize(:red) puts "Stack name #{stack_name} status #{stack["stack_status"]}" exit end end |
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jets/commands/deploy.rb', line 10 def run deployment_env = Jets.config.project_namespace.colorize(:green) puts "Deploying to Lambda #{deployment_env} environment..." return if @options[:noop] check_dev_mode build_code validate_routes! # first time will deploy minimal stack exit_unless_updateable! ship(stack_type: :minimal) if first_run? # deploy full nested stack when stack already exists ship(stack_type: :full, s3_bucket: s3_bucket) end |
#ship(stack_options) ⇒ Object
52 53 54 55 56 |
# File 'lib/jets/commands/deploy.rb', line 52 def ship() = @options.merge() # includes stack_type and s3_bucket Jets::Commands::Build.new().build_templates Jets::Cfn::Ship.new().run end |
#validate_routes! ⇒ Object
Checks that all routes are validate and have corresponding lambda functions
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/jets/commands/deploy.rb', line 41 def validate_routes! return if Jets::Router.all_routes_valid puts "Deploy fail: The jets application contain invalid routes.".colorize(:red) puts "Please double check the routes below map to valid controllers:" Jets::Router.invalid_routes.each do |route| puts " /#{route.path} => #{route.controller_name}##{route.action_name}" end exit 1 end |