ufo 3.5.4 → 3.5.5

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: 5a7fa29c3df7ba9a608f0e2c82fd27231fa6f083136ba3a08b987067518de477
4
- data.tar.gz: 94c3f8f4e5fc4b2cc9cf8fcac9ef49e42d876a137cfd414a10d62c915da7c96d
3
+ metadata.gz: 2f3cffb0c5f3bb15b7f6a236fab1821ec671a0a58f316d05546b0cc2343df31f
4
+ data.tar.gz: 0cbe0fe89dad15e6501ec136ecf5eb762861b6827939d520616d16d871a7bbaa
5
5
  SHA512:
6
- metadata.gz: eac7a33bea59ff2420a63ece5779c874a7b9bb03d6a5856417cb87d330a657a3fdb35888ee971545703b00bfa5e9887490efc0657cf0c4ccaeb6f717e9f29387
7
- data.tar.gz: b0b8e6d712982eea6a6f58c4eefbb172da9bfef85ae4e5a2d23e69c30fa47059238175bbb1c0902cade9f9af3a16d2bdfd8c66b072906076c6fd3017d1303209
6
+ metadata.gz: 19ccd9c0ed6f4cb8b2277e5895e3a92effdf47b40ea6424b1f64cc158f73182c402feebdc3fae45234b10b1b92f3b039b85b76ce5047fb61a554b42016a16f73
7
+ data.tar.gz: 633bc8eba241b343ee35e7927fd2d47bd609b5ca370096de8ab39581cd1608bac757e111a7b1cd02fc44b3b03b818a5848003523e84de57a6b32aab3980424cd
@@ -3,6 +3,12 @@
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
+ ## [3.5.5]
7
+ - Merge pull request #39 from hnatt/fix-docs
8
+ - Merge pull request #41 from tongueroo/params-template-scope
9
+ - add cloudwatch log info for the task command
10
+ - pass template scope to params erb evaluation
11
+
6
12
  ## [3.5.4]
7
13
  - Merge pull request #38 from tongueroo/docker-build-options
8
14
  - add ability to specify custom docker build options with env UFO_DOCKER_BUILD_OPTIONS variable
@@ -1,4 +1,4 @@
1
- # Contributing to Lono
1
+ # Contributing to ufo
2
2
 
3
3
  Contributing is welcomed and encouraged. We love pull requests!
4
4
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ufo (3.5.4)
4
+ ufo (3.5.5)
5
5
  aws-sdk-cloudwatchlogs
6
6
  aws-sdk-ec2
7
7
  aws-sdk-ecr
@@ -27,7 +27,7 @@ GEM
27
27
  aws-sdk-cloudwatchlogs (1.3.0)
28
28
  aws-sdk-core (~> 3)
29
29
  aws-sigv4 (~> 1.0)
30
- aws-sdk-core (3.21.1)
30
+ aws-sdk-core (3.21.2)
31
31
  aws-eventstream (~> 1.0)
32
32
  aws-partitions (~> 1.0)
33
33
  aws-sigv4 (~> 1.0)
@@ -38,10 +38,10 @@ GEM
38
38
  aws-sdk-ecr (1.3.0)
39
39
  aws-sdk-core (~> 3)
40
40
  aws-sigv4 (~> 1.0)
41
- aws-sdk-ecs (1.12.0)
41
+ aws-sdk-ecs (1.13.0)
42
42
  aws-sdk-core (~> 3)
43
43
  aws-sigv4 (~> 1.0)
44
- aws-sdk-elasticloadbalancingv2 (1.8.0)
44
+ aws-sdk-elasticloadbalancingv2 (1.9.0)
45
45
  aws-sdk-core (~> 3)
46
46
  aws-sigv4 (~> 1.0)
47
47
  aws-sigv4 (1.0.2)
@@ -31,13 +31,13 @@ end
31
31
 
32
32
  ## Web Role Convention
33
33
 
34
- By convention, if the service has a container name web, you'll get prompted to create an ELB and specify a target group arn. If you would like to name a service with the word "web" in it without having to use an ELB target group then you can use the `--no-target-group-prompt`. Example:
34
+ By convention, if the service has a container named "web", you'll get prompted to create an ELB and specify a target group ARN. If you would like to name a service with the word "web" in it without having to use an ELB target group then you can use the `--no-target-group-prompt`. Example:
35
35
 
36
36
  ```sh
37
37
  ufo ship hi-web --no-target-group-prompt
38
38
  ```
39
39
 
40
- You can also bypass the prompt by specifying the target group arn as part of the command upfront. The ELB and target group must already exist. The elb target group only gets associated when the service gets created for the first time. If the service already exists then the `--target-group` parameter just gets ignored and the ECS task simply gets updated. Example:
40
+ You can also bypass the prompt by specifying the target group ARN as part of the command upfront. The ELB and target group must already exist. The ELB target group only gets associated when the service gets created for the first time. If the service already exists then the `--target-group` parameter just gets ignored and the ECS task simply gets updated. Example:
41
41
 
42
42
  ```bash
43
43
  ufo ship hi-web --target-group=arn:aws:elasticloadbalancing:us-east-1:12345689:targetgroup/hi-web/12345
@@ -4,11 +4,12 @@ title: FAQ
4
4
 
5
5
  **Q: Is AWS ECS Fargate supported?**
6
6
 
7
- Yes, Fargate is supported. To use ufo with Fargate, you will need to adjust the template in `.ufo/templates` to use a structure support by Fargate. If it's a brand new project. You can use `ufo init` with the `--launch-type fargate` option and it will generate a starter JSON file that has the right Fargate structure. Notably, it has the requiresCompatibilities, networkMode, and executionRoleArn attributes.
7
+ Yes, Fargate is supported. To use ufo with Fargate, you will need to adjust the template in `.ufo/templates` to use a structure support by Fargate. There are 2 key items to adjust:
8
8
 
9
- The neat thing about Fargate is that can be an extremely cost-effective way to run one-off tasks. This blog post [Heroku vs ECS Fargate vs EC2 On-Demand vs EC2 Spot Pricing Comparison](https://blog.boltops.com/2018/04/22/heroku-vs-ecs-fargate-vs-ec2-on-demand-vs-ec2-spot-pricing-comparison) provides a relative comparison of costs.
9
+ 1. The task definition json. Notably, it has the `requiresCompatibilities`, `networkMode`, and `executionRoleArn` attributes. It also moves the `cpu` and `memory` outside of the `containerDefinitions` attributes to the root as top-level attributes. For details on how to adjust the task definition refer to [Task Definitions]({% link _docs/tutorial-ufo-tasks-build.md %}).
10
+ 2. The params that get sent to the `create_service` or `run_task` api methods. For details on how to adjust the params refer to [Params]({% link _docs/params.md %})
10
11
 
11
- ---
12
+ If it's a brand new project, you can use `ufo init` with the `--launch-type fargate` option and it will generate a starter JSON file that has the right Fargate structure. More info is available at [ufo init reference](/reference/ufo-init/#fargate-support).
12
13
 
13
14
  **Q: Can I tell ufo to use specific docker build options?**
14
15
 
@@ -74,7 +75,7 @@ Yes, this is achieved with the `--template` and `--template-mode` options when c
74
75
 
75
76
  ---
76
77
 
77
- **Q: How can I used syslog instead of awslogs for logging?**
78
+ **Q: How can I use syslog instead of awslogs for logging?**
78
79
 
79
80
  Open up `.ufo/templates/main.json.erb` - this gets created as part of the [ufo init](http://ufoships.com/reference/ufo-init/) command. Then you can adjust the ecs template definition to something like this:
80
81
 
@@ -86,7 +87,7 @@ Open up `.ufo/templates/main.json.erb` - this gets created as part of the [ufo i
86
87
 
87
88
  Here's the specific aws docs section [Specifying a Log Configuration in your Task Definition](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html#specify-log-config)
88
89
 
89
- Also, you might have to enable the log driver by added it the ECS_AVAILABLE_LOGGING_DRIVERS variable to your `/etc/ecs/ecs.config`. Relevant docs:
90
+ Also, you might have to enable the log driver by adding the ECS_AVAILABLE_LOGGING_DRIVERS variable to your `/etc/ecs/ecs.config`. Relevant docs:
90
91
 
91
92
  * [Using AWS Logs](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html#enable_awslogs)
92
93
  * [ECS Agent Install](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-install.html)
@@ -8,7 +8,7 @@ A common task is to run database migrations with newer code before deploying the
8
8
  ufo task hi-web --command bundle exec rake db:migrate
9
9
  ```
10
10
 
11
- It nice to wrap the commands in a wrapper script in case you have to do things like the load the environment.
11
+ It is nice to wrap the commands in a wrapper script in case you have to do things like to load the environment.
12
12
 
13
13
  ```sh
14
14
  ufo task hi-web --command bin/migrate
@@ -55,9 +55,11 @@ Ufo provides 1st class citizen access to adjust the params sent to the aws-sdk c
55
55
  * update_service - `ufo ship` calls this when the ECS service already exists.
56
56
  * run_task - `ufo task` calls this.
57
57
 
58
- The parameters from this `params.yml` file gets merged with params ufo generates internally. Here's an example of where the merging happens in the source code for the run task command [task.rb](https://github.com/tongueroo/ufo/blob/90f12df035843528770122deb328d150249a25e2/lib/ufo/task.rb#L20) Also, here's the starter [params.yml source code](https://github.com/tongueroo/ufo/blob/master/lib/template/.ufo/params.yml) for reference.
58
+ The parameters from this `params.yml` file get merged with params ufo generates internally. Here's an example of where the merging happens in the source code for the run task command [task.rb](https://github.com/tongueroo/ufo/blob/90f12df035843528770122deb328d150249a25e2/lib/ufo/task.rb#L20). Also, here's the starter [params.yml source code](https://github.com/tongueroo/ufo/blob/master/lib/template/.ufo/params.yml) for reference.
59
59
 
60
- ERB and variables are available in the params file. Noticed how ERB is used at the top of the example file to set some subnets to prevent duplication.
60
+ ERB and [shared variables]({% link _docs/variables.md %}) are available in the params file. Notice how ERB is used at the top of the example file to set some subnets to prevent duplication. You can also define the subnets in your config/variables and use them in them in the params.yml file.
61
+
62
+ NOTE: The params.yml file does not have access to the `task_definition_name` helper method. That is only available in the `task_definitions.rb` template_definition code blocks.
61
63
 
62
64
  <a id="prev" class="btn btn-basic" href="{% link _docs/settings.md %}">Back</a>
63
65
  <a id="next" class="btn btn-primary" href="{% link _docs/ufo-env.md %}">Next Step</a>
@@ -30,7 +30,7 @@ Update the service with the task definitions in `.ufo/output` untouched.
30
30
  ufo deploy hi-web
31
31
  ```
32
32
 
33
- Note if you use the `ufo deploy` you should ensure that you have already push the docker image to your docker registry. Or else the task will not be able to spin up because the docker image does not exist. This is one of the reasons it is recommended that you use `ufo ship`.
33
+ Note if you use the `ufo deploy` you should ensure that you have already pushed the docker image to your docker registry. Or else the task will not be able to spin up because the docker image does not exist. This is one of the reasons it is recommended that you use `ufo ship`.
34
34
 
35
35
  <a id="prev" class="btn btn-basic" href="{% link _docs/auto-completion.md %}">Back</a>
36
36
  <a id="next" class="btn btn-primary" href="{% link _docs/single-task.md %}">Next Step</a>
@@ -103,7 +103,7 @@ AWS_PROFILE=dev-profile2 => UFO_ENV=development
103
103
  AWS_PROFILE=prod-profile => UFO_ENV=production
104
104
  ```
105
105
 
106
- This behavior prevents you from switching `AWS_PROFILE`s and then accidentally deploying a production based docker image to development and vice versas because you forgot to also switch `UFO_ENV` to its respective environment.
106
+ This behavior prevents you from switching `AWS_PROFILE`s and then accidentally deploying a production based docker image to development and vice versa because you forgot to also switch `UFO_ENV` to its respective environment.
107
107
 
108
108
  <a id="prev" class="btn btn-basic" href="{% link _docs/structure.md %}">Back</a>
109
109
  <a id="next" class="btn btn-primary" href="{% link _docs/params.md %}">Next Step</a>
@@ -21,14 +21,14 @@ The table below covers the purpose of each folder and file.
21
21
 
22
22
  File / Directory | Description
23
23
  ------------- | -------------
24
- <code>output/</code> | The folder where the generated task definitions are written to. The way the task definitions are generated are covered in [ufo tasks build]({% link _docs/tutorial-ufo-tasks-build.md %}).
25
- <code>settings.yml</code> | Ufo's settings file, where you and adjust the default [settings]({% link _docs/settings.md %}).
26
- <code>task_definitions.rb</code> | This where you define the task definitions and specify the variables to be used by the ERB templates.
27
- <code>templates/</code> | The ERB templates with the task definition json code. The template are covered in more detail in [ufo tasks build]({% link _docs/tutorial-ufo-tasks-build.md %}).
24
+ <code>output/</code> | The folder where the generated task definitions are written to. The way the task definitions are generated is covered in [ufo tasks build]({% link _docs/tutorial-ufo-tasks-build.md %}).
25
+ <code>settings.yml</code> | Ufo's settings file, where you adjust the default [settings]({% link _docs/settings.md %}).
26
+ <code>task_definitions.rb</code> | This is where you define the task definitions and specify the variables to be used by the ERB templates.
27
+ <code>templates/</code> | The ERB templates with the task definition json code. The templates are covered in more detail in [ufo tasks build]({% link _docs/tutorial-ufo-tasks-build.md %}).
28
28
  <code>templates/main.json.erb</code> | This is the main and starter template task definition json file that ufo initially generates.
29
- <code>variables</code> | This is where you can define shared variables that are made available to the template_definitions.rb and your templates. More info at [Variables]({% link _docs/variables.md %}).
29
+ <code>variables</code> | This is where you can define shared variables that are made available to the `template_definitions.rb` and your templates. More info at [Variables]({% link _docs/variables.md %}).
30
30
 
31
- Now that you know where the ufo configurations are located and what they look like. Let use ufo!
31
+ Now that you know where the ufo configurations are located and what they look like, let’s use ufo!
32
32
 
33
33
  <a id="prev" class="btn btn-basic" href="{% link docs.md %}">Back</a>
34
34
  <a id="next" class="btn btn-primary" href="{% link _docs/settings.md %}">Next Step</a>
@@ -3,7 +3,7 @@ title: Setup Ufo
3
3
  ---
4
4
 
5
5
  The easiest way to create this ufo folder is by using the `ufo init` command. For this tutorial we'll [tongueroo/hi](https://github.com/tongueroo/hi) which is a small test sinatra app.
6
- Let's run the command in our newly clone project.
6
+ Let's run the command in our newly cloned project.
7
7
 
8
8
  ```sh
9
9
  git clone https://github.com/tongueroo/hi.git
@@ -27,7 +27,7 @@ If the ECS service hi-web does not yet exist, ufo will create the service for yo
27
27
 
28
28
  NOTE: If you are relying on this tool to create the cluster, you still need to associate ECS Container Instances to the cluster yourself.
29
29
 
30
- By convention, if the service has a container name web, you'll get prompted to create an ELB and specify a target group arn. The ELB and target group must already exist. You can bypass the prompt and specify the target group ARN as part of the ship command or with the `--no-target-group-prompt` option. The elb target group only gets associated with the ECS service if the service is being created for the first time. If the service already exists then the `--target-group` parameter just gets ignored and the ECS task simply gets updated. Example:
30
+ By convention, if the service has a container name web, you'll get prompted to create an ELB and specify a target group ARN. The ELB and target group must already exist. You can bypass the prompt and specify the target group ARN as part of the ship command or with the `--no-target-group-prompt` option. The ELB target group only gets associated with the ECS service if the service is being created for the first time. If the service already exists then the `--target-group` parameter just gets ignored and the ECS task simply gets updated. Example:
31
31
 
32
32
 
33
33
  ```bash
@@ -95,3 +95,6 @@ Normally you run everything together in one `ufo ship` command though. Ufo take
95
95
 
96
96
  Congratulations 🎊 You have successfully built a Docker image, register it and deployed it to AWS ECS.
97
97
 
98
+ <a id="prev" class="btn btn-basic" href="{% link _docs/tutorial-ufo-tasks-build.md %}">Back</a>
99
+ <a id="next" class="btn btn-primary" href="{% link _docs/tutorial-ufo-ships.md %}">Next Step</a>
100
+ <p class="keyboard-tip">Pro tip: Use the <- and -> arrow keys to move back and forward.</p>
@@ -8,12 +8,12 @@ Now that we have a docker image pushed to a registry we can use that image for E
8
8
 
9
9
  Let's take a look at the 2 files that are used by ufo to build the ECS task definition. These files were generated by the `ufo init` command at the beginning.
10
10
 
11
- 1. ufo/templates/main.json.erb
12
- 2. ufo/task_definitions.rb
11
+ 1. `.ufo/templates/main.json.erb`
12
+ 2. `.ufo/task_definitions.rb`
13
13
 
14
14
  Ufo task definitions are written as an ERB template that makes it every easily accessible and configurable to your requirements. Here is is an example of an ERB template `.ufo/templates/main.json.erb` that shows how easy it is to modfied the task definition you want to be uploaded by ufo:
15
15
 
16
- **ufo/templates/main.json.erb**:
16
+ **.ufo/templates/main.json.erb**:
17
17
 
18
18
  ```json
19
19
  {
@@ -36,7 +36,7 @@ Ufo task definitions are written as an ERB template that makes it every easily a
36
36
 
37
37
  The instance variable values are specified in `.ufo/task_definitions.rb` via a DSL. Here's the file:
38
38
 
39
- **ufo/task_definitions.rb**:
39
+ **.ufo/task_definitions.rb**:
40
40
 
41
41
  ```
42
42
  task_definition "hi-web" do
@@ -63,7 +63,7 @@ end
63
63
 
64
64
  Ufo has a concept of shared variables, covered in [Shared Variables]({% link _docs/variables.md %}). The shared variables are set in the `variables` folder and essentially allow you to use a set of shared variables through your templates:
65
65
 
66
- **ufo/variables/base.rb**:
66
+ **.ufo/variables/base.rb**:
67
67
 
68
68
  ```ruby
69
69
  @image = helper.full_image_name # includes the git sha tongueroo/hi:ufo-[sha].
@@ -72,7 +72,7 @@ Ufo has a concept of shared variables, covered in [Shared Variables]({% link _do
72
72
  @environment = helper.env_file(".env")
73
73
  ```
74
74
 
75
- **ufo/variables/development.rb**:
75
+ **.ufo/variables/development.rb**:
76
76
 
77
77
  ```ruby
78
78
  @environment = helper.env_vars(%Q{
@@ -85,7 +85,7 @@ Ufo combines the `main.json.erb` template, `task_definitions.rb` definitions, an
85
85
 
86
86
  If you need to modify the task definition template to suite your own needs it is super simple, just edit `main.json.erb`. You do not have to dive deep into internal code somewhere. It is all there for you to fully control.
87
87
 
88
- The task_definition.rb has access to some useful helper methods detailed in [Helpers]({% link _docs/helpers.md %}).
88
+ The `task_definition.rb` has access to some useful helper methods detailed in [Helpers]({% link _docs/helpers.md %}).
89
89
 
90
90
  Let's build the task definitions:
91
91
 
@@ -150,7 +150,7 @@ Let's take a look at one of the generated files: `.ufo/output/hi-web.json`.
150
150
 
151
151
  ## Register the ECS Task Definitions
152
152
 
153
- You have built the ecs task definitions locally on your machine. To register the task definitions in the `output` folder run:
153
+ You have built the ECS task definitions locally on your machine. To register the task definitions in the `output` folder run:
154
154
 
155
155
  ```sh
156
156
  ufo tasks register
@@ -27,7 +27,7 @@ ufo ship hi-web
27
27
 
28
28
  Most people will set `UFO_ENV` in their `~/.profile`.
29
29
 
30
- ## In ufo/settings.yml
30
+ ## In .ufo/settings.yml
31
31
 
32
32
  The most interesting way to set `UFO_ENV` is with the `aws_profiles` setting in `.ufo/settings.yml`. Let's say you have a `~/.ufo/settings.yml` with the following:
33
33
 
@@ -13,7 +13,7 @@ For example, given `variables/base.rb`:
13
13
  @environment = helper.env_file(".env")
14
14
  ```
15
15
 
16
- You can now use `@image` in your `.ufo/templates/main.json.erb` without having to explicitly declaring them in the `.ufo/task_definitions.rb` file. Variables are automatically made available to all templates and the `task_definition.rb` file also.
16
+ You can now use `@image` in your `.ufo/templates/main.json.erb` without having to explicitly declare them in the `.ufo/task_definitions.rb` file. Variables are automatically made available to all templates and the `task_definition.rb` file also.
17
17
 
18
18
  ## Layering
19
19
 
@@ -28,7 +28,7 @@ Shared variables also support a concept called layering. The `variables/base.rb
28
28
  @environment = helper.env_file(".env")
29
29
  ```
30
30
 
31
- When `ufo ship` is ran with `UFO_ENV=production` he `variables/production.rb` will be evaluated and layered on top of the variables defined in `base.rb`:
31
+ When `ufo ship` is ran with `UFO_ENV=production` the `variables/production.rb` will be evaluated and layered on top of the variables defined in `base.rb`:
32
32
 
33
33
  `.ufo/variables/production.rb`:
34
34
 
@@ -1,11 +1,11 @@
1
1
  require 'ostruct'
2
2
 
3
3
  module Ufo
4
- autoload :TaskDefinition, 'ufo/dsl/task_definition'
5
- autoload :Outputter, 'ufo/dsl/outputter'
6
- autoload :Helper, 'ufo/dsl/helper'
7
-
8
4
  class DSL
5
+ autoload :TaskDefinition, 'ufo/dsl/task_definition'
6
+ autoload :Outputter, 'ufo/dsl/outputter'
7
+ autoload :Helper, 'ufo/dsl/helper'
8
+
9
9
  def initialize(template_definitions_path, options={})
10
10
  @template_definitions_path = template_definitions_path
11
11
  @options = options
@@ -12,11 +12,15 @@ module Ufo
12
12
  def data
13
13
  upgrade_message!
14
14
 
15
- result = RenderMePretty.result(@params_path)
15
+ result = RenderMePretty.result(@params_path, context: template_scope)
16
16
  YAML.load(result)
17
17
  end
18
18
  memoize :data
19
19
 
20
+ def template_scope
21
+ @template_scope ||= Ufo::TemplateScope.new(Ufo::DSL::Helper.new, nil)
22
+ end
23
+
20
24
  # Ufo version 3.3 to 3.4 added a concept of a .ufo/params.yml file to support
21
25
  # fargate: https://github.com/tongueroo/ufo/pull/31
22
26
  #
@@ -1,5 +1,9 @@
1
+ require 'memoist'
2
+
1
3
  module Ufo
2
4
  class Task
5
+ extend Memoist
6
+
3
7
  include Util
4
8
  include AwsService
5
9
 
@@ -29,20 +33,51 @@ module Ufo
29
33
  puts "Running task with params:"
30
34
  display_params(task_options)
31
35
  end
32
- resp = ecs.run_task(task_options)
36
+
37
+ resp = run_task(task_options)
33
38
  unless @options[:mute]
34
39
  task_arn = resp.tasks[0].task_arn
35
40
  puts "Task ARN: #{task_arn}"
36
41
  puts " aws ecs describe-tasks --tasks #{task_arn} --cluster #{@cluster}"
37
- # todo: maybe add cw comand here also
42
+ cloudwatch_info(task_arn)
43
+ end
44
+ end
45
+
46
+ def run_task(options)
47
+ ecs.run_task(options)
48
+ rescue Aws::ECS::Errors::ClientException => e
49
+ if e.message =~ /ECS was unable to assume the role/
50
+ puts "ERROR: #{e.class} #{e.message}".colorize(:red)
51
+ puts "Please double check the executionRoleArn in your task definition."
52
+ exit 1
53
+ else
54
+ raise
38
55
  end
39
56
  end
40
57
 
41
58
  private
59
+ def cloudwatch_info(task_arn)
60
+ config = original_container_definition[:log_configuration]
61
+ container_name = original_container_definition[:name]
62
+
63
+ return unless config && config[:log_driver] == "awslogs"
64
+
65
+ log_group = config[:options]["awslogs-group"]
66
+ log_stream_prefix = config[:options]["awslogs-stream-prefix"]
67
+ task_id = task_arn.split('/').last
68
+ log_stream = "#{log_stream_prefix}/#{container_name}/#{task_id}"
69
+ # website/web/d473440a-9a0e-4262-a53d-f9e345cf2b7e
70
+ region = `aws configure get region`.strip rescue 'us-east-1'
71
+ url = "https://#{region}.console.aws.amazon.com/cloudwatch/home?region=#{region}#logEventViewer:group=#{log_group};stream=#{log_stream}"
72
+
73
+ puts "To see the task output visit CloudWatch:\n #{url}"
74
+ puts "NOTE: It will take some time for the log to show up because it takes time for the task to start. Run the `aws ecs describe-tasks` above for the task status."
75
+ end
76
+
42
77
  # only using the overrides to override the container command
43
78
  def overrides
44
79
  command = @options[:command] # Thor parser ensure this is always an array
45
- container_definition = get_original_container_definition
80
+ container_definition = original_container_definition
46
81
  {
47
82
  container_overrides: [
48
83
  {
@@ -54,7 +89,7 @@ module Ufo
54
89
  }
55
90
  end
56
91
 
57
- def get_original_container_definition
92
+ def original_container_definition
58
93
  resp = ecs.list_task_definitions(
59
94
  family_prefix: @task_definition,
60
95
  sort: "DESC"
@@ -65,5 +100,6 @@ module Ufo
65
100
  resp = ecs.describe_task_definition(task_definition: task_name)
66
101
  container_definition = resp.task_definition.container_definitions[0].to_h
67
102
  end
103
+ memoize :original_container_definition
68
104
  end
69
105
  end
@@ -1,3 +1,3 @@
1
1
  module Ufo
2
- VERSION = "3.5.4"
2
+ VERSION = "3.5.5"
3
3
  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: 3.5.4
4
+ version: 3.5.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: 2018-05-19 00:00:00.000000000 Z
11
+ date: 2018-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-cloudwatchlogs