Skip to content

Commit ecf1f75

Browse files
author
Tony Nyurkin
committed
Force users to specify color in cli
1 parent b0bd062 commit ecf1f75

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

bin/blue_green_switch

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ lb_name = ARGV[0]
77
lb_port = 443
88
domain = ARGV[1]
99
tg_prefix = ARGV[2]
10+
color = ARGV[3]
1011

1112
class AWSClient
1213
class << self
@@ -23,14 +24,14 @@ rule = AWSClient.elbv2.describe_rules(listener_arn: listener.listener_arn).rules
2324
tg_green = AWSClient.elbv2.describe_target_groups.target_groups.find { |x| x.target_group_name == "#{tg_prefix}-green" }
2425
tg_blue = AWSClient.elbv2.describe_target_groups.target_groups.find { |x| x.target_group_name == "#{tg_prefix}-blue" }
2526

26-
if rule.actions.first.target_group_arn.include? "blue"
27-
puts "Detected blue tg, switching to green"
27+
if color == "green"
28+
puts "Switching to green"
2829
tg_color = tg_green.target_group_arn
29-
elsif rule.actions.first.target_group_arn.include? "green"
30-
puts "Detected green tg, switching to blue"
30+
elsif color == "blue"
31+
puts "Switching to blue"
3132
tg_color = tg_blue.target_group_arn
3233
else
33-
fail "Cannot detect current color"
34+
fail "Cannot detect current color. Color not passed in cli?"
3435
end
3536

3637
targets = AWSClient.elbv2.describe_target_health(target_group_arn: tg_color)

deploy-tools.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22
s.name = 'deploy-tools'
3-
s.version = '0.0.4'
4-
s.date = '2020-09-15'
3+
s.version = '0.0.5'
4+
s.date = '2021-03-17'
55
s.summary = "Deploy tools"
66
s.description = "A set of script used for deployment"
77
s.authors = ["Tony Nyurkin"]

0 commit comments

Comments
 (0)