ufo 6.0.5 → 6.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 731c8ef178a8fe9586b08eef48c7cdc4b1014e58b601155a46bed1f0c5657afa
4
- data.tar.gz: 1654ffccfb5a57827b63e4cf8777f2ff0884e52a4e29ee0591296947443e8189
3
+ metadata.gz: 0ebcf583b29f7a6bd3e78d01091d1c993799b3ee3b30f139ae13fec372ca6328
4
+ data.tar.gz: 745a00ef65d3788e2b986f33cde18d763ee2167f205e1e7ed2d4340be2383529
5
5
  SHA512:
6
- metadata.gz: ebf9a0cbd7b7d2b532c85a8776180475d38ae5fdb4bd2b0dd1cc4ce93df3546b9af65385e3632cc936a0825e1252377c354ed4c409cb8f9723bcf0baa9a09134
7
- data.tar.gz: '0913ec88f24b35bd34208cdbc286fcd1a1ad021538feebb66e7d9fff7bfb2eaeba7d902f5581a3003a1dc92f8a491b09bb9aab25fc0b21f4c788194c5b487f4a'
6
+ metadata.gz: c511ee4143f521d907ffd066fa2bd2c15b8dbad9a4e647e7646418ed936a7c3f4956f8e142eb551c53990be6bb6ae049bd29c6022dcefd311a420ba204f725ae
7
+ data.tar.gz: e55927bdc1d09f921c35f27ceaac142022d7fd2a73fefd0fa9e96cff6b846340e01f540be09669f0f03ab31c8c39e4f16ed60202b20cb47d02fee5ab9235c21d
data/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
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.8] - 2022-03-10
7
+ - [#135](https://github.com/tongueroo/ufo/pull/135) improve .ufo/config/boot.rb location
8
+ - change default config.ship.docker.quiet to false
9
+
10
+ ## [6.0.7] - 2022-03-07
11
+ - fix autoscaling.manual_changes.retain check
12
+ - improve Configured autoscaling message
13
+
14
+ ## [6.0.6] - 2022-03-07
15
+ - [#134](https://github.com/tongueroo/ufo/pull/134) config.autoscaling.manual_changes.retain support
16
+ - change default `elb.healthy_threshold_count = 3`
17
+ - change default `config.ship.docker.quiet = true`
18
+ - config.autoscaling.manual_changes.retain support
19
+ - fix yaml validator print code
20
+ - ship cli help
21
+
6
22
  ## [6.0.5] - 2022-03-07
7
23
  - change default config.ship.docker.quiet = true
8
24
 
@@ -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,
data/lib/ufo/booter.rb CHANGED
@@ -18,7 +18,7 @@ module Ufo
18
18
 
19
19
  def run_hook(env=nil)
20
20
  name = env ? "boot/#{env}" : "boot"
21
- path = "#{Ufo.root}/.ufo/#{name}.rb" # IE: .ufo/boot/dev.rb
21
+ path = "#{Ufo.root}/.ufo/config/#{name}.rb" # IE: .ufo/boot/dev.rb
22
22
  require path if File.exist?(path)
23
23
  end
24
24
 
@@ -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
@@ -46,7 +46,10 @@ class Ufo::CLI
46
46
  r.logical_resource_id == "ScalingTarget"
47
47
  end
48
48
  register_scalable_target(scalable_target)
49
- logger.info "Configured autoscaling to min: #{@min} max: #{@max}"
49
+ to = []
50
+ to << "min: #{@min}" if @min
51
+ to << "max: #{@max}" if @max
52
+ logger.info "Configured autoscaling to #{to.join(' ')}"
50
53
  end
51
54
 
52
55
  def register_scalable_target(scalable_target)
@@ -65,18 +68,21 @@ class Ufo::CLI
65
68
  end
66
69
 
67
70
  def warning
68
- return unless Ufo.config.scale.warning
71
+ autoscaling = Ufo.config.autoscaling
72
+ return if autoscaling.manual_changes.warning == false or autoscaling.manual_changes.retain
69
73
  logger.info <<~EOL
70
74
  Note: The settings are temporary.
71
75
  They can be overwritten in the next `ufo ship` deploy.
72
- To make the settings permanent update your ufo config.
73
76
 
74
- See: https://ufoships.com/docs/config/
77
+ You can turn off this warning with
75
78
 
76
- You can also turn off this warning with
79
+ config.autoscaling.warning = false
77
80
 
78
- config.scale.warning = false
81
+ Or you can use the
79
82
 
83
+ config.autoscaling.manual_changes.retain = true
84
+
85
+ For considerations, see: https://ufoships.com/docs/features/autoscaling/
80
86
  EOL
81
87
  end
82
88
  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,9 +109,6 @@ 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
114
  config.ship.docker.quiet = false # only affects ufo ship docker commands output
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.8"
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,14 +1,14 @@
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.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-07 00:00:00.000000000 Z
11
+ date: 2022-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-logs