ufo 6.0.5 → 6.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 731c8ef178a8fe9586b08eef48c7cdc4b1014e58b601155a46bed1f0c5657afa
4
- data.tar.gz: 1654ffccfb5a57827b63e4cf8777f2ff0884e52a4e29ee0591296947443e8189
3
+ metadata.gz: 87344022dcbcd4b41904a181613e3eb4bbe8985577517d9633efb8f2b3795249
4
+ data.tar.gz: 7f3d119496e82275a92f0b8b867bb08025c76955de837b33cddb39bdc835466c
5
5
  SHA512:
6
- metadata.gz: ebf9a0cbd7b7d2b532c85a8776180475d38ae5fdb4bd2b0dd1cc4ce93df3546b9af65385e3632cc936a0825e1252377c354ed4c409cb8f9723bcf0baa9a09134
7
- data.tar.gz: '0913ec88f24b35bd34208cdbc286fcd1a1ad021538feebb66e7d9fff7bfb2eaeba7d902f5581a3003a1dc92f8a491b09bb9aab25fc0b21f4c788194c5b487f4a'
6
+ metadata.gz: 8964557bdb9b5a1958f22a3f72f6719de1c9a97fb2b5ca1e4b7961bc61cdb912817147246e86568c21ec2ba10fad0c9e5f5dc53c8bec2d6c92d86221df09711c
7
+ data.tar.gz: a12c83ff26e2b0177e2ec9311f07a71fe1b5f9689663e45fd6267edfe4570795c31aab9f6dc06d2e059ae37711bb0017f1a7fce995ad1532aea942d09bbe6961
data/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
5
5
 
6
+ ## [6.0.6] - 2022-03-07
7
+ - [#134](https://github.com/tongueroo/ufo/pull/134) config.autoscaling.manual_changes.retain support
8
+ - change default `elb.healthy_threshold_count = 3`
9
+ - change default `config.ship.docker.quiet = true`
10
+ - config.autoscaling.manual_changes.retain support
11
+ - fix yaml validator print code
12
+ - ship cli help
13
+
6
14
  ## [6.0.5] - 2022-03-07
7
15
  - change default config.ship.docker.quiet = true
8
16
 
@@ -4,36 +4,37 @@ Ufo.configure do |config|
4
4
  config.docker.repo = "<%= @repo %>"
5
5
  # config.ecs.cluster = ":ENV" # :ENV pattern is replaced with UFO_ENV. Default is UFO_ENV=dev
6
6
 
7
- # See VPC Docs: https://ufoships.com/docs/config/vpc/
7
+ # VPC Docs: https://ufoships.com/docs/config/vpc/
8
8
  # When not set, it's assumed that the ECS cluster using default vpc and default subnets.
9
9
  # Notice the ability to use `stack_output` helpers to set the values.
10
10
  # config.vpc.id = stack_output("vpc-:ENV.Vpc")
11
11
  # config.vpc.subnets.ecs = stack_output("vpc-:ENV.PrivateAppSubnets").split(',')
12
12
  # config.vpc.subnets.elb = stack_output("vpc-:ENV.PublicSubnets").split(',')
13
13
 
14
- # See AutoScaling Docs: https://ufoships.com/docs/features/autoscaling/
14
+ # AutoScaling Docs: https://ufoships.com/docs/features/autoscaling/
15
15
  # config.autoscaling.enabled = true
16
- # config.autoscaling.min_capacity = 2
16
+ # config.autoscaling.manual_changes.retain = false
17
17
  # config.autoscaling.max_capacity = 3
18
+ # config.autoscaling.min_capacity = 2
18
19
  # config.autoscaling.target_value = 50.0
19
20
 
20
- # See Route DNS Docs: https://ufoships.com/docs/features/dns-route53-support/
21
+ # Route DNS Docs: https://ufoships.com/docs/features/dns-route53-support/
21
22
  # config.dns.domain = "domain.com"
22
23
 
23
- # See ufo exec Docs: https://ufoships.com/docs/intro/ufo-exec/
24
+ # Ufo exec Docs: https://ufoships.com/docs/intro/ufo-exec/
24
25
  # bash is default but may not be available your Docker image
25
26
  # Configure to /bin/sh if needed
26
- # config.ecs.default_execute_command = "/bin/bash"
27
+ # config.exec.command = "/bin/bash"
27
28
 
28
- # See: https://ufoships.com/docs/config/reference/
29
+ # Docs: https://ufoships.com/docs/config/reference/
29
30
  # config.ps.summary = false # false to turn off the summary at top of ufo ps output
30
31
  # config.ps.format = "table" # Examples: csv table tab json
31
32
 
32
- # See: https://ufoships.com/docs/config/reference/
33
+ # Docs: https://ufoships.com/docs/config/reference/
33
34
  # Note: the `-` (minus sign) in front rejects the pattern
34
35
  # config.logs.filter_pattern = '- "HealthChecker"'
35
36
 
36
- # See: https://ufoships.com/docs/config/reference/
37
+ # Docs: https://ufoships.com/docs/config/reference/
37
38
  # You may want to set to false if your docker build and push process takes a while
38
39
  # config.ship.docker.quiet = false # default is true.
39
40
  end
@@ -103,6 +103,13 @@ module Ufo
103
103
  end
104
104
  end
105
105
 
106
+ def stack_resources(stack_name)
107
+ resp = cloudformation.describe_stack_resources(stack_name: stack_name)
108
+ resp.stack_resources
109
+ rescue Aws::CloudFormation::Errors::ValidationError => e
110
+ e.message.include?("does not exist") ? return : raise
111
+ end
112
+
106
113
  def task_definition_arns(family, max_items=10)
107
114
  resp = ecs.list_task_definitions(
108
115
  family_prefix: family,
@@ -13,10 +13,35 @@ module Ufo::Cfn::Stack::Builder::Resources::Scaling
13
13
  - [service, #{@cluster}, !GetAtt [EcsService, Name]]
14
14
  ServiceNamespace: ecs
15
15
  ScalableDimension: ecs:service:DesiredCount
16
- MinCapacity: #{autoscaling.min_capacity}
17
- MaxCapacity: #{autoscaling.max_capacity}
16
+ MinCapacity: #{min_capacity}
17
+ MaxCapacity: #{max_capacity}
18
18
  EOL
19
19
  Ufo::Yaml.load(text).deep_symbolize_keys
20
20
  end
21
+
22
+ private
23
+ def min_capacity
24
+ return autoscaling.min_capacity if vars[:new_stack] && !autoscaling.manual_changes.retain
25
+ scalable_target ? scalable_target.min_capacity : autoscaling.min_capacity
26
+ end
27
+
28
+ def max_capacity
29
+ return autoscaling.max_capacity if vars[:new_stack] && !autoscaling.manual_changes.retain
30
+ scalable_target ? scalable_target.max_capacity : autoscaling.max_capacity
31
+ end
32
+
33
+ def scalable_target
34
+ resources = stack_resources(vars[:stack_name])
35
+ return unless resources
36
+ ecs_service = resources.find { |r| r.logical_resource_id == "EcsService" }
37
+ service_name = File.basename(ecs_service.physical_resource_id) # IE: demo-web-dev-EcsService-Tw0nPMgpkmm4
38
+ resource_id = "service/#{vars[:cluster]}/#{service_name}"
39
+ resp = applicationautoscaling.describe_scalable_targets(
40
+ service_namespace: "ecs",
41
+ resource_ids: [resource_id],
42
+ )
43
+ resp.scalable_targets.first
44
+ end
45
+ memoize :scalable_target
21
46
  end
22
47
  end
@@ -1,33 +1,41 @@
1
1
  class Ufo::Cfn::Stack
2
2
  class Vars < Ufo::Cfn::Base
3
3
  attr_reader :stack_name
4
- def initialize(options={})
5
- super
6
- @cluster = options[:cluster].dup # Thor options are frozen, we thaw it because CustomProperties#substitute_variables does a sub!
7
- @stack_name = options[:stack_name] || [Ufo.app, @task_definition.role, Ufo.env].join('-')
8
- @stack = options[:stack]
9
- @new_stack = !@stack
10
- end
11
4
 
12
5
  def values
6
+ # Not passing stack down to vars beause its easier to debug. Will require another lookup by thats ok
13
7
  {
14
8
  cluster: @cluster,
15
- stack_name: @stack_name, # used in custom_properties
16
9
  container: container,
17
- # to reconstruct TaskDefinition in the CloudFormation template
18
- task_definition: @task_definition,
19
- rollback_task_definition: @options[:rollback_task_definition],
20
- # elb options remember that their 'state'
21
10
  create_elb: create_elb?, # helps set Ecs DependsOn
22
- elb_type: elb_type,
11
+ create_listener_ssl: create_listener_ssl?,
23
12
  create_route53: create_elb? && dns_configured?,
24
- default_target_group_protocol: default_target_group_protocol,
25
13
  default_listener_protocol: default_listener_protocol,
26
14
  default_listener_ssl_protocol: default_listener_ssl_protocol,
27
- create_listener_ssl: create_listener_ssl?,
15
+ default_target_group_protocol: default_target_group_protocol,
16
+ elb_type: elb_type,
17
+ new_stack: new_stack,
18
+ rollback_task_definition: rollback_task_definition,
19
+ stack_name: @stack_name, # used in custom_properties
20
+ task_definition: @task_definition, # to reconstruct TaskDefinition for CloudFormation template
28
21
  }
29
22
  end
30
23
 
24
+ def new_stack
25
+ !stack
26
+ end
27
+
28
+ # Find stack in vars to ensure both ufo build and ufo ship can tell if stack has already been built
29
+ def stack
30
+ find_stack(@stack_name)
31
+ end
32
+ memoize :stack
33
+
34
+ def rollback_task_definition
35
+ return unless @options[:rollback]
36
+ @options[:rollback_task_definition]
37
+ end
38
+
31
39
  def dns_configured?
32
40
  !!Ufo.config.dns.domain || !!Ufo.config.dns.name
33
41
  end
data/lib/ufo/cfn/stack.rb CHANGED
@@ -78,35 +78,19 @@ module Ufo::Cfn
78
78
  end
79
79
 
80
80
  def build
81
- options_with_vars = @options.dup.merge(vars: vars.values)
81
+ vars = Vars.new(@options).values
82
+ options_with_vars = @options.dup.merge(vars: vars)
82
83
  params = Params.new(options_with_vars)
83
84
  @parameters = params.build
84
85
  template = Template.new(options_with_vars)
85
86
  @template_body = template.body
86
87
  end
87
88
 
88
- def vars
89
- o = @options.merge(
90
- cluster: @cluster,
91
- stack_name: @stack_name,
92
- stack: @stack,
93
- )
94
- o[:rollback_task_definition] = rollback_task_definition if rollback_task_definition
95
- Vars.new(o)
96
- end
97
- memoize :vars
98
-
99
89
  def scheduling_strategy
100
90
  scheduling_strategy = Ufo.config.ecs.scheduling_strategy
101
91
  scheduling_strategy.upcase if scheduling_strategy
102
92
  end
103
93
 
104
- def rollback_task_definition
105
- return unless @options[:rollback]
106
- @options[:rollback_task_definition]
107
- end
108
- memoize :rollback_task_definition
109
-
110
94
  def exit_with_message(stack)
111
95
  url = "https://console.aws.amazon.com/cloudformation/home?region=#{region}#/stacks"
112
96
  logger.info "The stack is not in an updateable state: #{stack.stack_status.color(:yellow)}."
@@ -4,10 +4,6 @@ Here's an example:
4
4
 
5
5
  ufo ship
6
6
 
7
- Let's deploy
8
-
9
- ufo ship
10
-
11
7
  You will be prompted to confirm before deployment.
12
8
 
13
9
  $ ufo ship
data/lib/ufo/cli/scale.rb CHANGED
@@ -65,18 +65,21 @@ class Ufo::CLI
65
65
  end
66
66
 
67
67
  def warning
68
- return unless Ufo.config.scale.warning
68
+ autoscaling = Ufo.config.autoscaling
69
+ return if autoscaling.manual_changes.warning == false or autoscaling.manual_changes.retain
69
70
  logger.info <<~EOL
70
71
  Note: The settings are temporary.
71
72
  They can be overwritten in the next `ufo ship` deploy.
72
- To make the settings permanent update your ufo config.
73
73
 
74
- See: https://ufoships.com/docs/config/
74
+ You can turn off this warning with
75
75
 
76
- You can also turn off this warning with
76
+ config.autoscaling.warning = false
77
77
 
78
- config.scale.warning = false
78
+ Or you can use the
79
79
 
80
+ config.autoscaling.manual_changes.retain = true
81
+
82
+ For considerations, see: https://ufoships.com/docs/features/autoscaling/
80
83
  EOL
81
84
  end
82
85
  end
data/lib/ufo/config.rb CHANGED
@@ -21,6 +21,9 @@ module Ufo
21
21
 
22
22
  config.autoscaling = ActiveSupport::OrderedOptions.new
23
23
  config.autoscaling.enabled = true
24
+ config.autoscaling.manual_changes = ActiveSupport::OrderedOptions.new
25
+ config.autoscaling.manual_changes.retain = false
26
+ config.autoscaling.manual_changes.warning = true
24
27
  config.autoscaling.max_capacity = 5 # dont use max thats an OrderedOptions method
25
28
  config.autoscaling.min_capacity = 1 # dont use min thats an OrderedOptions method
26
29
  config.autoscaling.predefined_metric_type = "ECSServiceAverageCPUUtilization"
@@ -28,6 +31,7 @@ module Ufo
28
31
  config.autoscaling.scale_out_cooldown = nil
29
32
  config.autoscaling.target_value = 75.0
30
33
 
34
+
31
35
  config.cfn = ActiveSupport::OrderedOptions.new
32
36
  config.cfn.disable_rollback = nil
33
37
  config.cfn.notification_arns = nil
@@ -59,9 +63,9 @@ module Ufo
59
63
  config.elb.default_actions = nil # full override
60
64
  config.elb.enabled = "auto" # "auto", true or false
61
65
 
62
- config.elb.health_check_interval_seconds = 10
66
+ config.elb.health_check_interval_seconds = 10 # keep at 10 in case of network ELB, which is min 10
63
67
  config.elb.health_check_path = nil # When nil its AWS default /
64
- config.elb.healthy_threshold_count = 5
68
+ config.elb.healthy_threshold_count = 3 # The AWS usual default is 5
65
69
  config.elb.unhealthy_threshold_count = 2
66
70
 
67
71
  config.elb.port = 80 # default listener port
@@ -105,12 +109,9 @@ module Ufo
105
109
  config.secrets.pattern.ssm = ":APP/:ENV/:SECRET_NAME" # => demo/dev/DB_PASS
106
110
  config.secrets.provider = "ssm" # default provider for conventional expansion IE: ssm or secretsmanager
107
111
 
108
- config.scale = ActiveSupport::OrderedOptions.new
109
- config.scale.warning = true
110
-
111
112
  config.ship = ActiveSupport::OrderedOptions.new
112
113
  config.ship.docker = ActiveSupport::OrderedOptions.new
113
- config.ship.docker.quiet = false # only affects ufo ship docker commands output
114
+ config.ship.docker.quiet = true # only affects ufo ship docker commands output
114
115
 
115
116
  config.state = ActiveSupport::OrderedOptions.new
116
117
  config.state.reminder = true
data/lib/ufo/info.rb CHANGED
@@ -64,7 +64,7 @@ module Ufo
64
64
  dns_name = output.output_value if output
65
65
  return unless dns_name
66
66
 
67
- ssl = stack_resources.detect.find do |r|
67
+ ssl = stack_resources.find do |r|
68
68
  r.logical_resource_id == "ListenerSsl"
69
69
  end
70
70
 
data/lib/ufo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ufo
2
- VERSION = "6.0.5"
2
+ VERSION = "6.0.6"
3
3
  end
@@ -28,7 +28,7 @@ class Ufo::Yaml
28
28
  md = e.message.match(/at line (\d+) column (\d+)/)
29
29
  line = md[1].to_i
30
30
 
31
- DslEvaluator.print_code(path, line_number)
31
+ DslEvaluator.print_code(path, line)
32
32
  exit 1
33
33
  end
34
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ufo
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.5
4
+ version: 6.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen