class Hashicorptools::CodeDeploy
Constants
- AWS_REGION_US_EAST_1
Public Instance Methods
deploy()
click to toggle source
# File lib/hashicorptools/code_deploy.rb, line 55 def deploy g = Git.open('..') # We set defaults (depending on environment) for aws_regions if not passed in aws_regions = options[:aws_regions] || default_regions commit = if options[:commit].present? g.gcommit(options[:commit]) else branch = options[:branch].nil? ? :main : options[:branch].to_sym g.checkout(branch) g.log.first end puts "Deploying to environment #{options[:environment]} - regions: #{aws_regions.join(', ')} commit: #{commit.sha} message: #{commit.message}" puts "Deploying for regions: #{aws_regions}" threads = [] aws_regions.each_slice(2) do |aws_regions_batch| puts "Deploying for batch of regions: #{aws_regions_batch}" aws_regions_batch.each do |aws_region| thread = Thread.new{ region_deployment(aws_region).create_deployment(commit.sha, commit.message) } threads.push(thread) end threads.each_with_index do |thread, index| begin thread.join rescue Exception => e # Don't quit whole program on exception in thread, just print exception and exit thread puts "[#{aws_regions[index]}] EXCEPTION: #{e}" end end end end
Private Instance Methods
default_regions()
click to toggle source
# File lib/hashicorptools/code_deploy.rb, line 100 def default_regions [AWS_REGION_US_EAST_1] end
region_deployment(aws_region)
click to toggle source
# File lib/hashicorptools/code_deploy.rb, line 96 def region_deployment(aws_region) RegionDeployment.new(aws_region: aws_region, environment: options[:environment]) end