ufo 6.3.2 → 6.3.5
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 +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/ufo/cfn/stack/builder/base.rb +7 -6
- data/lib/ufo/cfn/stack/builder/resources/security_group/ecs.rb +2 -1
- data/lib/ufo/cfn/stack/builder/resources/security_group/ecs_rule.rb +1 -2
- data/lib/ufo/cfn/stack/builder/resources/security_group/elb.rb +1 -1
- data/lib/ufo/cli/logs.rb +27 -9
- data/lib/ufo/cli/new/init.rb +0 -9
- data/lib/ufo/cli/ps/task.rb +28 -4
- data/lib/ufo/cli.rb +1 -0
- data/lib/ufo/config.rb +1 -2
- data/lib/ufo/ext/core/module.rb +12 -1
- data/lib/ufo/info.rb +12 -3
- data/lib/ufo/task_definition/helpers/{vars/aws_helper.rb → aws_helper.rb} +1 -1
- data/lib/ufo/task_definition/helpers/vars/builder.rb +1 -1
- data/lib/ufo/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7412fed5f36c54bd78f76bfb6debb841d3f867ea25ef4625a31c9e205a1e955
|
4
|
+
data.tar.gz: a0d91c95a050d2fbce2731c10387651fb2909c3dc65a4e2af60a6cf780d3e1b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ee413ef0571f90417c37327d78fbb86c8fab10584746dfcbec86d292ce3f8dad8d31d53d3a939db6b9a2f91639d50ed4f876262d84c40c453ad22e610a7b46f
|
7
|
+
data.tar.gz: c8fe10ab749b98820faa9105584175b1c97cfcd7ecee92a1bf75e7d1623ed158c86b2ac32a834a8f4b617e252dca6c28682f8a3e4664f8dac03785117ab26bb8
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,18 @@
|
|
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.3.5] - 2022-04-28
|
7
|
+
- [#171](https://github.com/tongueroo/ufo/pull/171) default unhealthy_threshold_count = 3
|
8
|
+
|
9
|
+
## [6.3.4] - 2022-04-27
|
10
|
+
- [#168](https://github.com/tongueroo/ufo/pull/168) ufo ps: show multiple container names
|
11
|
+
- [#169](https://github.com/tongueroo/ufo/pull/169) ufo logs improvements
|
12
|
+
- [#170](https://github.com/tongueroo/ufo/pull/170) infer ecs managed sg based on awsvpc network mode
|
13
|
+
|
14
|
+
## [6.3.3] - 2022-03-27
|
15
|
+
- [#167](https://github.com/tongueroo/ufo/pull/167) fix edge case include_dir for ruby 2.7
|
16
|
+
- remove update_dockerignore
|
17
|
+
|
6
18
|
## [6.3.2] - 2022-03-26
|
7
19
|
- [#164](https://github.com/tongueroo/ufo/pull/164) existing elb target group support
|
8
20
|
- [#165](https://github.com/tongueroo/ufo/pull/165) improve secrets support
|
@@ -18,22 +18,23 @@ class Ufo::Cfn::Stack::Builder
|
|
18
18
|
def security_groups(type)
|
19
19
|
group_ids = Ufo.config.vpc.security_groups[type] || []
|
20
20
|
# no security groups at all
|
21
|
-
return if !
|
21
|
+
return if type == :ecs && !manage_ecs_security_group? && group_ids.blank?
|
22
22
|
|
23
23
|
groups = []
|
24
24
|
groups += group_ids
|
25
|
-
groups += [managed_security_group(type
|
25
|
+
groups += [managed_security_group(type)] if manage_ecs_security_group? || type == :elb
|
26
26
|
groups
|
27
27
|
end
|
28
28
|
|
29
29
|
def managed_security_group(type)
|
30
|
-
logical_id =
|
30
|
+
logical_id = type == :elb || manage_ecs_security_group? ? "#{type.to_s.camelize}SecurityGroup" : "AWS::NoValue"
|
31
31
|
{Ref: logical_id}
|
32
32
|
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
# With network mode is awsvpc always create UFO managed ECS security group
|
35
|
+
# With bridge mode, never create as there's no point.
|
36
|
+
def manage_ecs_security_group?
|
37
|
+
vars[:container][:network_mode].to_s == 'awsvpc'
|
37
38
|
end
|
38
39
|
|
39
40
|
def self.build(options={})
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Ufo::Cfn::Stack::Builder::Resources::SecurityGroup
|
2
2
|
class Ecs < Base
|
3
3
|
def build
|
4
|
-
return unless
|
4
|
+
return unless manage_ecs_security_group?
|
5
|
+
return unless vars[:container][:network_mode].to_s == 'awsvpc'
|
5
6
|
|
6
7
|
{
|
7
8
|
Type: "AWS::EC2::SecurityGroup",
|
@@ -1,8 +1,7 @@
|
|
1
1
|
module Ufo::Cfn::Stack::Builder::Resources::SecurityGroup
|
2
2
|
class EcsRule < Base
|
3
3
|
def build
|
4
|
-
return unless
|
5
|
-
return unless vars[:elb_type] == "application"
|
4
|
+
return unless manage_ecs_security_group?
|
6
5
|
|
7
6
|
{
|
8
7
|
Type: "AWS::EC2::SecurityGroupIngress",
|
data/lib/ufo/cli/logs.rb
CHANGED
@@ -6,11 +6,11 @@ class Ufo::CLI
|
|
6
6
|
|
7
7
|
def run
|
8
8
|
log = find_log_group_name
|
9
|
-
|
9
|
+
logger.info "Showing logs for stack: #{@stack_name} log group: #{log["awslogs-group"]} and stream prefix: #{log["awslogs-stream-prefix"]}"
|
10
10
|
if log
|
11
11
|
cloudwatch_tail(log)
|
12
12
|
else
|
13
|
-
|
13
|
+
logger.info "Unable to find log group for service: #{service.service_name}"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -24,22 +24,40 @@ class Ufo::CLI
|
|
24
24
|
|
25
25
|
container_definitions = resp.task_definition.container_definitions
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
if container_definitions.size > 1 && !@options[:container]
|
28
|
+
logger.info "Multiple containers found. ufo logs will use the first container."
|
29
|
+
logger.info "You can also use the --container option to set the container to use."
|
30
|
+
end
|
31
|
+
|
32
|
+
definition = if @options[:container]
|
33
|
+
container_definitions.find do |c|
|
34
|
+
c.name == @options[:container]
|
35
|
+
end
|
36
|
+
else
|
37
|
+
container_definitions.first
|
38
|
+
end
|
39
|
+
|
40
|
+
unless definition
|
41
|
+
logger.error "ERROR: unable to find a container".color(:red)
|
42
|
+
logger.error "You specified --container #{@options[:container]}" if @options[:container]
|
43
|
+
exit
|
30
44
|
end
|
31
45
|
|
32
|
-
definition = container_definitions.first
|
33
46
|
log_conf = definition.log_configuration
|
47
|
+
unless log_conf
|
48
|
+
logger.error "ERROR: Unable to find a log_configuration for container: #{definition.name}".color(:red)
|
49
|
+
logger.error "You specified --container #{@options[:container]}" if @options[:container]
|
50
|
+
exit 1
|
51
|
+
end
|
34
52
|
|
35
|
-
if log_conf
|
53
|
+
if log_conf.log_driver == "awslogs"
|
36
54
|
# options["awslogs-group"]
|
37
55
|
# options["awslogs-region"]
|
38
56
|
# options["awslogs-stream-prefix"]
|
39
57
|
log_conf.options
|
40
58
|
else
|
41
|
-
|
42
|
-
|
59
|
+
logger.error "ERROR: Only supports awslogs driver. Detected log_driver: #{log_conf.log_driver}".color(:red)
|
60
|
+
exit 1 unless ENV['UFO_TEST']
|
43
61
|
end
|
44
62
|
end
|
45
63
|
|
data/lib/ufo/cli/new/init.rb
CHANGED
@@ -39,15 +39,6 @@ class Ufo::CLI::New
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def update_dockerignore
|
43
|
-
text = ".ufo\n"
|
44
|
-
if File.exist?(".dockerignore")
|
45
|
-
append_to_file ".dockerignore", text
|
46
|
-
else
|
47
|
-
create_file ".dockerignore", text
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
42
|
def create_dockefile
|
52
43
|
return if File.exist?("Dockerfile")
|
53
44
|
set_template_source("docker")
|
data/lib/ufo/cli/ps/task.rb
CHANGED
@@ -16,12 +16,36 @@ class Ufo::CLI::Ps
|
|
16
16
|
|
17
17
|
def name
|
18
18
|
container_overrides = @task.dig("overrides", "container_overrides")
|
19
|
-
overrides = container_overrides
|
20
|
-
|
19
|
+
overrides = container_overrides # assume first is one we want
|
20
|
+
if !overrides.empty? # PENDING wont yet have info
|
21
|
+
overrides.map { |i| i["name"] }.join(',')
|
22
|
+
else
|
23
|
+
container_names
|
24
|
+
end
|
21
25
|
rescue NoMethodError
|
22
|
-
|
23
|
-
|
26
|
+
container_names
|
27
|
+
end
|
28
|
+
|
29
|
+
# PENDING wont yet have any containers yet but since using task definition we're ok
|
30
|
+
def container_names
|
31
|
+
task_definition = task_definition(@task.task_definition_arn)
|
32
|
+
names = task_definition.container_definitions.map do |container_definition|
|
33
|
+
container_definition.name
|
34
|
+
end
|
35
|
+
names.join(',')
|
36
|
+
end
|
37
|
+
|
38
|
+
# ECS inconsistently returns the container names in random order
|
39
|
+
# Look up the names from the task definition to try and get right order
|
40
|
+
# This still seems to return inconsistently.
|
41
|
+
# IE: Not the order that was defined in the task definition originally
|
42
|
+
def task_definition(task_definition_arn)
|
43
|
+
resp = ecs.describe_task_definition(
|
44
|
+
task_definition: task_definition_arn,
|
45
|
+
)
|
46
|
+
resp.task_definition
|
24
47
|
end
|
48
|
+
memoize :task_definition
|
25
49
|
|
26
50
|
def container_instance_arn
|
27
51
|
@task['container_instance_arn'].split('/').last
|
data/lib/ufo/cli.rb
CHANGED
@@ -64,6 +64,7 @@ module Ufo
|
|
64
64
|
option :since, desc: "From what time to begin displaying logs. By default, logs will be displayed starting from 1 minutes in the past. The value provided can be an ISO 8601 timestamp or a relative time."
|
65
65
|
option :format, default: "short", desc: "The format to display the logs. IE: detailed or short. With detailed, the log stream name is also shown."
|
66
66
|
option :filter_pattern, desc: "The filter pattern to use. If not provided, all the events are matched"
|
67
|
+
option :container, aliases: :c, desc: "Container name to show logs for. Only needed when ECS task multiple containers"
|
67
68
|
def logs
|
68
69
|
Logs.new(options).run
|
69
70
|
end
|
data/lib/ufo/config.rb
CHANGED
@@ -70,7 +70,7 @@ module Ufo
|
|
70
70
|
config.elb.health_check_interval_seconds = 10 # keep at 10 in case of network ELB, which is min 10
|
71
71
|
config.elb.health_check_path = nil # When nil its AWS default /
|
72
72
|
config.elb.healthy_threshold_count = 3 # The AWS usual default is 5
|
73
|
-
config.elb.unhealthy_threshold_count =
|
73
|
+
config.elb.unhealthy_threshold_count = 3
|
74
74
|
|
75
75
|
config.elb.port = 80 # default listener port
|
76
76
|
config.elb.redirect = ActiveSupport::OrderedOptions.new
|
@@ -138,7 +138,6 @@ module Ufo
|
|
138
138
|
config.vpc.security_groups = ActiveSupport::OrderedOptions.new
|
139
139
|
config.vpc.security_groups.ecs = nil
|
140
140
|
config.vpc.security_groups.elb = nil
|
141
|
-
config.vpc.security_groups.managed = true
|
142
141
|
config.vpc.subnets = ActiveSupport::OrderedOptions.new
|
143
142
|
config.vpc.subnets.ecs = nil
|
144
143
|
config.vpc.subnets.elb = nil
|
data/lib/ufo/ext/core/module.rb
CHANGED
@@ -17,10 +17,21 @@ class Module
|
|
17
17
|
parent_dir = File.dirname(calling_file)
|
18
18
|
|
19
19
|
full_dir = "#{parent_dir}/#{dir}"
|
20
|
-
|
20
|
+
# Tricky: Only include top-level dir. Do not include subdirs.
|
21
|
+
# Fixes ruby 2.7 issue where just calling constantize on Vars::Builder
|
22
|
+
# triggers Ufo::Config::CallableOption::Concern to load and causes
|
23
|
+
# And causes some helper methods to be missing. Error looks like this:
|
24
|
+
#
|
25
|
+
# undefined method `stack_output' for #<Ufo::Config:0x0000000006585268>
|
26
|
+
#
|
27
|
+
# This is because stack_output is loaded after afterwards.
|
28
|
+
#
|
29
|
+
paths = Dir.glob("#{full_dir}/*.rb")
|
21
30
|
if paths.empty?
|
22
31
|
raise "Empty include_modules full_dir: #{full_dir}"
|
23
32
|
end
|
33
|
+
|
34
|
+
paths.sort_by! { |p| p.size }
|
24
35
|
paths.each do |path|
|
25
36
|
regexp = Regexp.new(".*/lib/")
|
26
37
|
mod = path.sub(regexp, '').sub('.rb','').camelize
|
data/lib/ufo/info.rb
CHANGED
@@ -23,9 +23,18 @@ module Ufo
|
|
23
23
|
load_balancer = service.load_balancers.first
|
24
24
|
return unless load_balancer
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
begin
|
27
|
+
resp = elb.describe_target_groups(
|
28
|
+
target_group_arns: [load_balancer.target_group_arn]
|
29
|
+
)
|
30
|
+
rescue Aws::ElasticLoadBalancingV2::Errors::TargetGroupNotFound
|
31
|
+
# Super edge case when:
|
32
|
+
# 1. deploy with ELB
|
33
|
+
# 2. deploy again without ELB
|
34
|
+
# 3. ECS service sometimes still thinks there's an ELB
|
35
|
+
# Error: https://gist.github.com/tongueroo/dc41f408e65414ab5ee864d0d738d81a
|
36
|
+
return
|
37
|
+
end
|
29
38
|
target_group = resp.target_groups.first
|
30
39
|
load_balancer_arn = target_group.load_balancer_arns.first # assume first only
|
31
40
|
return unless load_balancer_arn # can occur while stack is being deleted
|
@@ -3,9 +3,9 @@ require "aws_data"
|
|
3
3
|
module Ufo::TaskDefinition::Helpers::Vars
|
4
4
|
class Builder
|
5
5
|
extend Memoist
|
6
|
-
include AwsHelper
|
7
6
|
include Ufo::Concerns::Names
|
8
7
|
include Ufo::Config::CallableOption::Concern
|
8
|
+
include Ufo::TaskDefinition::Helpers::AwsHelper
|
9
9
|
include Ufo::Utils::CallLine
|
10
10
|
include Ufo::Utils::Logging
|
11
11
|
include Ufo::Utils::Pretty
|
data/lib/ufo/version.rb
CHANGED
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.3.
|
4
|
+
version: 6.3.5
|
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-
|
11
|
+
date: 2022-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-logs
|
@@ -648,6 +648,7 @@ files:
|
|
648
648
|
- lib/ufo/task_definition/erb/yaml.rb
|
649
649
|
- lib/ufo/task_definition/helpers.rb
|
650
650
|
- lib/ufo/task_definition/helpers/acm.rb
|
651
|
+
- lib/ufo/task_definition/helpers/aws_helper.rb
|
651
652
|
- lib/ufo/task_definition/helpers/docker.rb
|
652
653
|
- lib/ufo/task_definition/helpers/ecr.rb
|
653
654
|
- lib/ufo/task_definition/helpers/expansion.rb
|
@@ -655,7 +656,6 @@ files:
|
|
655
656
|
- lib/ufo/task_definition/helpers/ssm/fetcher.rb
|
656
657
|
- lib/ufo/task_definition/helpers/stack_output.rb
|
657
658
|
- lib/ufo/task_definition/helpers/vars.rb
|
658
|
-
- lib/ufo/task_definition/helpers/vars/aws_helper.rb
|
659
659
|
- lib/ufo/task_definition/helpers/vars/builder.rb
|
660
660
|
- lib/ufo/task_definition/helpers/vpc.rb
|
661
661
|
- lib/ufo/task_definition/helpers/waf.rb
|
@@ -716,7 +716,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
716
716
|
- !ruby/object:Gem::Version
|
717
717
|
version: '0'
|
718
718
|
requirements: []
|
719
|
-
rubygems_version: 3.
|
719
|
+
rubygems_version: 3.3.12
|
720
720
|
signing_key:
|
721
721
|
specification_version: 4
|
722
722
|
summary: AWS ECS Deploy Tool
|