ufo 4.5.7 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +2 -0
- data/docs/_docs/conventions.md +1 -1
- data/docs/_docs/extras/codebuild-iam-role.md +2 -2
- data/docs/_docs/extras/dockerfile-erb.md +2 -2
- data/docs/_docs/extras/ecs-network-mode.md +2 -2
- data/docs/_docs/extras/load-balancer.md +2 -2
- data/docs/_docs/extras/minimal-deploy-iam.md +2 -2
- data/docs/_docs/extras/redirection-support.md +2 -2
- data/docs/_docs/extras/route53-support.md +2 -2
- data/docs/_docs/extras/security-groups.md +2 -2
- data/docs/_docs/extras/ssl-support.md +2 -2
- data/docs/_docs/faq.md +2 -2
- data/docs/_docs/helpers.md +1 -1
- data/docs/_docs/install.md +1 -1
- data/docs/_docs/more/auto-completion.md +2 -2
- data/docs/_docs/more/automated-cleanup.md +2 -2
- data/docs/_docs/more/customize-cloudformation.md +2 -2
- data/docs/_docs/more/migrations.md +2 -2
- data/docs/_docs/more/run-in-pieces.md +2 -2
- data/docs/_docs/more/single-task.md +2 -2
- data/docs/_docs/more/stuck-cloudformation.md +2 -2
- data/docs/_docs/more/why-cloudformation.md +2 -2
- data/docs/_docs/next-steps.md +2 -2
- data/docs/_docs/quick-start-ec2.md +1 -1
- data/docs/_docs/settings.md +1 -1
- data/docs/_docs/settings/aws_profile.md +1 -1
- data/docs/_docs/settings/cfn.md +1 -1
- data/docs/_docs/settings/cluster.md +1 -1
- data/docs/_docs/settings/network.md +1 -1
- data/docs/_docs/ssl_errors.md +40 -0
- data/docs/_docs/structure.md +1 -1
- data/docs/_docs/tutorial-ufo-docker-build.md +1 -1
- data/docs/_docs/tutorial-ufo-init.md +1 -1
- data/docs/_docs/tutorial-ufo-ship.md +1 -1
- data/docs/_docs/tutorial-ufo-ships.md +1 -1
- data/docs/_docs/tutorial-ufo-tasks-build.md +1 -1
- data/docs/_docs/tutorial.md +1 -1
- data/docs/_docs/ufo-current.md +2 -2
- data/docs/_docs/ufo-env-extra.md +2 -2
- data/docs/_docs/ufo-env.md +2 -2
- data/docs/_docs/ufo-logs.md +50 -0
- data/docs/_docs/ufo-task-params.md +2 -2
- data/docs/_docs/upgrading.md +2 -2
- data/docs/_docs/upgrading/upgrade4.5.md +2 -2
- data/docs/_docs/upgrading/upgrade4.md +2 -2
- data/docs/_docs/variables.md +1 -1
- data/docs/_includes/subnav.html +2 -1
- data/docs/_reference/ufo-logs.md +39 -0
- data/docs/articles.md +2 -2
- data/docs/docs.md +1 -1
- data/docs/quick-start.md +1 -1
- data/docs/reference.md +1 -0
- data/docs/utils/ssl-doctor.rb +89 -0
- data/docs/utils/test-aws-api-access.rb +11 -0
- data/docs/utils/update-cert-chains.sh +11 -0
- data/lib/template/.ufo/settings/cfn/default.yml.tt +1 -1
- data/lib/ufo/aws_service.rb +2 -0
- data/lib/ufo/cancel.rb +1 -1
- data/lib/ufo/cli.rb +9 -0
- data/lib/ufo/core.rb +5 -5
- data/lib/ufo/help/logs.md +10 -0
- data/lib/ufo/logs.rb +55 -0
- data/lib/ufo/version.rb +1 -1
- data/spec/fixtures/mocks/logs/awslogs.json +70 -0
- data/spec/fixtures/mocks/logs/no-awslogs.json +70 -0
- data/spec/lib/logs_spec.rb +55 -0
- data/ufo.gemspec +2 -0
- metadata +45 -4
data/lib/ufo/logs.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require "aws-logs"
|
2
|
+
|
3
|
+
module Ufo
|
4
|
+
class Logs < Base
|
5
|
+
include AwsService
|
6
|
+
|
7
|
+
delegate :service, to: :info
|
8
|
+
|
9
|
+
def run
|
10
|
+
log = find_log_group_name
|
11
|
+
puts "Showing logs for log group: #{log["awslogs-group"]} and stream prefix #{log["awslogs-stream-prefix"]}"
|
12
|
+
if log
|
13
|
+
cloudwatch_tail(log)
|
14
|
+
else
|
15
|
+
puts "Unable to find log group for service: #{service.service_name}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def find_log_group_name
|
20
|
+
resp = ecs.describe_task_definition(task_definition: info.service.task_definition)
|
21
|
+
|
22
|
+
container_definitions = resp.task_definition.container_definitions
|
23
|
+
|
24
|
+
unless container_definitions.size == 1
|
25
|
+
puts "ERROR: ufo logs command only supports 1 container definition in the ECS task definition".color(:red)
|
26
|
+
return
|
27
|
+
end
|
28
|
+
|
29
|
+
definition = container_definitions.first
|
30
|
+
log_conf = definition.log_configuration
|
31
|
+
|
32
|
+
if log_conf && log_conf.log_driver == "awslogs"
|
33
|
+
# options["awslogs-group"]
|
34
|
+
# options["awslogs-region"]
|
35
|
+
# options["awslogs-stream-prefix"]
|
36
|
+
log_conf.options
|
37
|
+
else
|
38
|
+
puts "Only supports awslogs driver. Detected log_driver: #{log_conf.log_driver}"
|
39
|
+
return
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def cloudwatch_tail(log={})
|
44
|
+
since = @options[:since] || "10m" # by default, search only 10 mins in the past
|
45
|
+
cw_tail = AwsLogs::Tail.new(
|
46
|
+
log_group_name: log["awslogs-group"],
|
47
|
+
log_stream_name_prefix: log["awslogs-stream-prefix"],
|
48
|
+
since: since,
|
49
|
+
follow: @options[:follow],
|
50
|
+
format: @options[:format],
|
51
|
+
)
|
52
|
+
cw_tail.run
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/ufo/version.rb
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
{
|
2
|
+
"task_definition": {
|
3
|
+
"task_definition_arn": "arn:aws:ecs:us-west-2:112233445566:task-definition/demo-web:1",
|
4
|
+
"container_definitions": [
|
5
|
+
{
|
6
|
+
"name": "web",
|
7
|
+
"image": "112233445566.dkr.ecr.us-west-2.amazonaws.com/demo/sinatra:ufo-2020-01-16T22-56-26-a28378e80",
|
8
|
+
"cpu": 256,
|
9
|
+
"memory": 1024,
|
10
|
+
"memory_reservation": 1024,
|
11
|
+
"port_mappings": [
|
12
|
+
{
|
13
|
+
"container_port": 4567,
|
14
|
+
"host_port": 4567,
|
15
|
+
"protocol": "tcp"
|
16
|
+
}
|
17
|
+
],
|
18
|
+
"essential": true,
|
19
|
+
"command": [
|
20
|
+
"bin/web"
|
21
|
+
],
|
22
|
+
"environment": [],
|
23
|
+
"log_configuration": {
|
24
|
+
"log_driver": "awslogs",
|
25
|
+
"options": {
|
26
|
+
"awslogs-group": "ecs/demo-web",
|
27
|
+
"awslogs-region": "us-west-2",
|
28
|
+
"awslogs-stream-prefix": "demo"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
],
|
33
|
+
"family": "demo-web",
|
34
|
+
"task_role_arn": "arn:aws:iam::112233445566:role/demo",
|
35
|
+
"network_mode": "awsvpc",
|
36
|
+
"revision": 1,
|
37
|
+
"volumes": [
|
38
|
+
],
|
39
|
+
"status": "ACTIVE",
|
40
|
+
"requires_attributes": [
|
41
|
+
{
|
42
|
+
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"name": "com.amazonaws.ecs.capability.ecr-auth"
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"name": "com.amazonaws.ecs.capability.task-iam-role"
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"name": "ecs.capability.task-eni"
|
61
|
+
}
|
62
|
+
],
|
63
|
+
"placement_constraints": [
|
64
|
+
|
65
|
+
],
|
66
|
+
"compatibilities": [
|
67
|
+
"EC2"
|
68
|
+
]
|
69
|
+
}
|
70
|
+
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
{
|
2
|
+
"task_definition": {
|
3
|
+
"task_definition_arn": "arn:aws:ecs:us-west-2:112233445566:task-definition/demo-web:1",
|
4
|
+
"container_definitions": [
|
5
|
+
{
|
6
|
+
"name": "web",
|
7
|
+
"image": "112233445566.dkr.ecr.us-west-2.amazonaws.com/demo/sinatra:ufo-2020-01-16T22-56-26-a28378e80",
|
8
|
+
"cpu": 256,
|
9
|
+
"memory": 1024,
|
10
|
+
"memory_reservation": 1024,
|
11
|
+
"port_mappings": [
|
12
|
+
{
|
13
|
+
"container_port": 4567,
|
14
|
+
"host_port": 4567,
|
15
|
+
"protocol": "tcp"
|
16
|
+
}
|
17
|
+
],
|
18
|
+
"essential": true,
|
19
|
+
"command": [
|
20
|
+
"bin/web"
|
21
|
+
],
|
22
|
+
"environment": [],
|
23
|
+
"log_configuration": {
|
24
|
+
"log_driver": "whatever",
|
25
|
+
"options": {
|
26
|
+
"awslogs-group": "ecs/demo-web",
|
27
|
+
"awslogs-region": "us-west-2",
|
28
|
+
"awslogs-stream-prefix": "demo"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
],
|
33
|
+
"family": "demo-web",
|
34
|
+
"task_role_arn": "arn:aws:iam::112233445566:role/demo",
|
35
|
+
"network_mode": "awsvpc",
|
36
|
+
"revision": 1,
|
37
|
+
"volumes": [
|
38
|
+
],
|
39
|
+
"status": "ACTIVE",
|
40
|
+
"requires_attributes": [
|
41
|
+
{
|
42
|
+
"name": "com.amazonaws.ecs.capability.logging-driver.awslogs"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"name": "com.amazonaws.ecs.capability.ecr-auth"
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.19"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.21"
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"name": "com.amazonaws.ecs.capability.task-iam-role"
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"name": "ecs.capability.task-eni"
|
61
|
+
}
|
62
|
+
],
|
63
|
+
"placement_constraints": [
|
64
|
+
|
65
|
+
],
|
66
|
+
"compatibilities": [
|
67
|
+
"EC2"
|
68
|
+
]
|
69
|
+
}
|
70
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
describe Ufo::Logs do
|
2
|
+
let(:logs) do
|
3
|
+
logs = Ufo::Logs.new("test-web", {})
|
4
|
+
allow(logs).to receive(:exit).and_return(null)
|
5
|
+
allow(logs).to receive(:info).and_return(null)
|
6
|
+
allow(logs).to receive(:ecs).and_return(ecs)
|
7
|
+
logs
|
8
|
+
end
|
9
|
+
let(:ecs) do
|
10
|
+
ecs = double(:ecs).as_null_object
|
11
|
+
allow(ecs).to receive(:describe_task_definition).and_return(mock_response(fixture))
|
12
|
+
ecs
|
13
|
+
end
|
14
|
+
let(:null) { double(:null).as_null_object }
|
15
|
+
|
16
|
+
context "awslogs conf" do
|
17
|
+
let(:fixture) { "spec/fixtures/mocks/logs/awslogs.json" }
|
18
|
+
it "find_log_group_name" do
|
19
|
+
log_group_name = logs.find_log_group_name
|
20
|
+
expect(log_group_name).to eq({"awslogs-group" => "ecs/demo-web", "awslogs-region" => "us-west-2", "awslogs-stream-prefix" => "demo" })
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "not a awslogs conf" do
|
25
|
+
let(:fixture) { "spec/fixtures/mocks/logs/no-awslogs.json" }
|
26
|
+
it "find_log_group_name" do
|
27
|
+
log_group_name = logs.find_log_group_name
|
28
|
+
expect(log_group_name).to be nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def mock_response(file)
|
33
|
+
data = JSON.load(IO.read(file))
|
34
|
+
|
35
|
+
td = data["task_definition"]
|
36
|
+
container_definitions = td["container_definitions"].map do |c|
|
37
|
+
l = c["log_configuration"]
|
38
|
+
log_configuration = Aws::ECS::Types::LogConfiguration.new(
|
39
|
+
log_driver: l["log_driver"],
|
40
|
+
options: l["options"],
|
41
|
+
)
|
42
|
+
Aws::ECS::Types::ContainerDefinition.new(
|
43
|
+
name: c["name"],
|
44
|
+
log_configuration: log_configuration,
|
45
|
+
)
|
46
|
+
end
|
47
|
+
task_definition = Aws::ECS::Types::TaskDefinition.new(
|
48
|
+
task_definition_arn: td["task_definition_arn"],
|
49
|
+
container_definitions: container_definitions,
|
50
|
+
)
|
51
|
+
Aws::ECS::Types::DescribeTaskDefinitionResponse.new(
|
52
|
+
task_definition: task_definition,
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
data/ufo.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency "aws-logs"
|
22
|
+
spec.add_dependency "aws-mfa-secure"
|
21
23
|
spec.add_dependency "aws-sdk-cloudformation"
|
22
24
|
spec.add_dependency "aws-sdk-cloudwatchlogs"
|
23
25
|
spec.add_dependency "aws-sdk-ec2"
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ufo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-logs
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-mfa-secure
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: aws-sdk-cloudformation
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -297,7 +325,6 @@ files:
|
|
297
325
|
- README.md
|
298
326
|
- Rakefile
|
299
327
|
- docs/.gitignore
|
300
|
-
- docs/.ruby-version
|
301
328
|
- docs/CNAME
|
302
329
|
- docs/Gemfile
|
303
330
|
- docs/LICENSE
|
@@ -333,6 +360,7 @@ files:
|
|
333
360
|
- docs/_docs/settings/cfn.md
|
334
361
|
- docs/_docs/settings/cluster.md
|
335
362
|
- docs/_docs/settings/network.md
|
363
|
+
- docs/_docs/ssl_errors.md
|
336
364
|
- docs/_docs/structure.md
|
337
365
|
- docs/_docs/tutorial-ufo-docker-build.md
|
338
366
|
- docs/_docs/tutorial-ufo-init.md
|
@@ -343,6 +371,7 @@ files:
|
|
343
371
|
- docs/_docs/ufo-current.md
|
344
372
|
- docs/_docs/ufo-env-extra.md
|
345
373
|
- docs/_docs/ufo-env.md
|
374
|
+
- docs/_docs/ufo-logs.md
|
346
375
|
- docs/_docs/ufo-task-params.md
|
347
376
|
- docs/_docs/ufo-tasks-register.md
|
348
377
|
- docs/_docs/upgrading.md
|
@@ -399,6 +428,7 @@ files:
|
|
399
428
|
- docs/_reference/ufo-docker-push.md
|
400
429
|
- docs/_reference/ufo-docker.md
|
401
430
|
- docs/_reference/ufo-init.md
|
431
|
+
- docs/_reference/ufo-logs.md
|
402
432
|
- docs/_reference/ufo-network-help.md
|
403
433
|
- docs/_reference/ufo-network-init.md
|
404
434
|
- docs/_reference/ufo-network.md
|
@@ -459,6 +489,9 @@ files:
|
|
459
489
|
- docs/quick-start.md
|
460
490
|
- docs/reference.md
|
461
491
|
- docs/style.css
|
492
|
+
- docs/utils/ssl-doctor.rb
|
493
|
+
- docs/utils/test-aws-api-access.rb
|
494
|
+
- docs/utils/update-cert-chains.sh
|
462
495
|
- exe/ufo
|
463
496
|
- lib/cfn/stack.yml
|
464
497
|
- lib/template/.env
|
@@ -526,6 +559,7 @@ files:
|
|
526
559
|
- lib/ufo/help/docker/push.md
|
527
560
|
- lib/ufo/help/help.md
|
528
561
|
- lib/ufo/help/init.md
|
562
|
+
- lib/ufo/help/logs.md
|
529
563
|
- lib/ufo/help/network/init.md
|
530
564
|
- lib/ufo/help/ps.md
|
531
565
|
- lib/ufo/help/releases.md
|
@@ -543,6 +577,7 @@ files:
|
|
543
577
|
- lib/ufo/info.rb
|
544
578
|
- lib/ufo/init.rb
|
545
579
|
- lib/ufo/log_group.rb
|
580
|
+
- lib/ufo/logs.rb
|
546
581
|
- lib/ufo/network.rb
|
547
582
|
- lib/ufo/network/fetch.rb
|
548
583
|
- lib/ufo/network/helper.rb
|
@@ -586,6 +621,8 @@ files:
|
|
586
621
|
- spec/fixtures/dockerfiles/ecr/Dockerfile
|
587
622
|
- spec/fixtures/home_existing/.aws/config
|
588
623
|
- spec/fixtures/home_existing/.docker/config.json
|
624
|
+
- spec/fixtures/mocks/logs/awslogs.json
|
625
|
+
- spec/fixtures/mocks/logs/no-awslogs.json
|
589
626
|
- spec/fixtures/ps/describe_tasks.json
|
590
627
|
- spec/fixtures/settings.yml
|
591
628
|
- spec/lib/apps_spec.rb
|
@@ -594,6 +631,7 @@ files:
|
|
594
631
|
- spec/lib/completion_spec.rb
|
595
632
|
- spec/lib/ecr_auth_spec.rb
|
596
633
|
- spec/lib/ecr_cleaner_spec.rb
|
634
|
+
- spec/lib/logs_spec.rb
|
597
635
|
- spec/lib/ps_spec.rb
|
598
636
|
- spec/lib/register_spec.rb
|
599
637
|
- spec/lib/setting_spec.rb
|
@@ -622,7 +660,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
622
660
|
- !ruby/object:Gem::Version
|
623
661
|
version: '0'
|
624
662
|
requirements: []
|
625
|
-
rubygems_version: 3.
|
663
|
+
rubygems_version: 3.1.2
|
626
664
|
signing_key:
|
627
665
|
specification_version: 4
|
628
666
|
summary: AWS ECS Deploy Tool
|
@@ -637,6 +675,8 @@ test_files:
|
|
637
675
|
- spec/fixtures/dockerfiles/ecr/Dockerfile
|
638
676
|
- spec/fixtures/home_existing/.aws/config
|
639
677
|
- spec/fixtures/home_existing/.docker/config.json
|
678
|
+
- spec/fixtures/mocks/logs/awslogs.json
|
679
|
+
- spec/fixtures/mocks/logs/no-awslogs.json
|
640
680
|
- spec/fixtures/ps/describe_tasks.json
|
641
681
|
- spec/fixtures/settings.yml
|
642
682
|
- spec/lib/apps_spec.rb
|
@@ -645,6 +685,7 @@ test_files:
|
|
645
685
|
- spec/lib/completion_spec.rb
|
646
686
|
- spec/lib/ecr_auth_spec.rb
|
647
687
|
- spec/lib/ecr_cleaner_spec.rb
|
688
|
+
- spec/lib/logs_spec.rb
|
648
689
|
- spec/lib/ps_spec.rb
|
649
690
|
- spec/lib/register_spec.rb
|
650
691
|
- spec/lib/setting_spec.rb
|