ufo 4.4.2 → 4.4.3

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
  SHA1:
3
- metadata.gz: 7d98dc4756c6e74a03e33965e204e3d1e7df743e
4
- data.tar.gz: fea753dd83bdeb2928e1947cf2e0f9290c7db3f5
3
+ metadata.gz: 2f3d71a890dc7dac92751517b4aecc81cbaf37d8
4
+ data.tar.gz: 00b13ce41a1175c882fef6fbc0d3df52ac0b5636
5
5
  SHA512:
6
- metadata.gz: 2f08996b96a47e48349552d4ce47eeb823e9340c92c1a4f9f1c8fc77738864a5c00e2481a63184ec8af4256b68b7a6f11d6acd7abcdf15d153e79ad2369d48a1
7
- data.tar.gz: e9cc6d0790208fcb42590269eb632aa7e654b571f316704d1cd2809e6c85a7cd1ad3e66cfe4e8c3485a4b2e55fdb9c18587fe8a81381f38710451c893bd1d151
6
+ metadata.gz: 70244a2dcc77c9bee7b1586745490fcff58cc7056be81597dfb3434c09caad7831909927419bd4920b490adb57ede2e1335f7ba6c5c8a2444fe14aab07ce5da4
7
+ data.tar.gz: ec407342a7d7c7520d6c33d99d1df53731a06692f238f5dacde6c774b4bac0a50737f7b16a0e25ed4d3445f6f0148738f584f8c230db66f6a2ca8f3ad95fe5f3
data/CHANGELOG.md CHANGED
@@ -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
+ ## [4.4.3]
7
+ - fix edge case when target group name is too long: only occurs with UFO\_FORCE\_TARGET_GROUP mode
8
+ - stdout sync true for improved codebuild status
9
+ - ufo network init ecs-subnets and elb-subnets options
10
+ - update docs: use ecr repo in quick start examples
11
+
6
12
  ## [4.4.2]
7
13
  - fix current_region for codebuild
8
14
 
data/Gemfile.lock CHANGED
@@ -24,30 +24,30 @@ GEM
24
24
  i18n (>= 0.7, < 2)
25
25
  minitest (~> 5.1)
26
26
  tzinfo (~> 1.1)
27
- aws-eventstream (1.0.2)
28
- aws-partitions (1.151.0)
29
- aws-sdk-cloudformation (1.18.0)
30
- aws-sdk-core (~> 3, >= 3.48.2)
27
+ aws-eventstream (1.0.3)
28
+ aws-partitions (1.171.0)
29
+ aws-sdk-cloudformation (1.22.0)
30
+ aws-sdk-core (~> 3, >= 3.53.0)
31
31
  aws-sigv4 (~> 1.1)
32
- aws-sdk-cloudwatchlogs (1.17.0)
33
- aws-sdk-core (~> 3, >= 3.48.2)
32
+ aws-sdk-cloudwatchlogs (1.20.0)
33
+ aws-sdk-core (~> 3, >= 3.53.0)
34
34
  aws-sigv4 (~> 1.1)
35
- aws-sdk-core (3.48.4)
35
+ aws-sdk-core (3.54.2)
36
36
  aws-eventstream (~> 1.0, >= 1.0.2)
37
37
  aws-partitions (~> 1.0)
38
38
  aws-sigv4 (~> 1.1)
39
39
  jmespath (~> 1.0)
40
- aws-sdk-ec2 (1.79.0)
41
- aws-sdk-core (~> 3, >= 3.48.2)
40
+ aws-sdk-ec2 (1.89.0)
41
+ aws-sdk-core (~> 3, >= 3.53.0)
42
42
  aws-sigv4 (~> 1.1)
43
- aws-sdk-ecr (1.14.0)
44
- aws-sdk-core (~> 3, >= 3.48.2)
43
+ aws-sdk-ecr (1.17.0)
44
+ aws-sdk-core (~> 3, >= 3.53.0)
45
45
  aws-sigv4 (~> 1.1)
46
- aws-sdk-ecs (1.36.0)
47
- aws-sdk-core (~> 3, >= 3.48.2)
46
+ aws-sdk-ecs (1.40.0)
47
+ aws-sdk-core (~> 3, >= 3.53.0)
48
48
  aws-sigv4 (~> 1.1)
49
- aws-sdk-elasticloadbalancingv2 (1.26.0)
50
- aws-sdk-core (~> 3, >= 3.48.2)
49
+ aws-sdk-elasticloadbalancingv2 (1.29.0)
50
+ aws-sdk-core (~> 3, >= 3.53.0)
51
51
  aws-sigv4 (~> 1.1)
52
52
  aws-sigv4 (1.1.0)
53
53
  aws-eventstream (~> 1.0, >= 1.0.2)
@@ -0,0 +1,46 @@
1
+ ---
2
+ title: CodeBuild IAM Role
3
+ nav_order: 29
4
+ ---
5
+
6
+ Note, the `/tmp/ecs-deploy-policy.json` policy is available at [Minimal Deploy IAM]({% link _docs/extras/minimal-deploy-iam.md %}).
7
+
8
+ ## Existing IAM Role
9
+
10
+ If you're using CodeBuild with `ufo ship` to handle deployments, you can use the same policy for the role that you assign to the the CodeBuild project and attach it to the the CodeBuild service IAM role that is usually created with the CodeBuild Console wizard. For example, of the IAM role was called `codebuild-myapp-service-role`:
11
+
12
+ aws iam put-role-policy --role-name codebuild-myapp-service-role --policy-name EcsDeployPolicy --policy-document file:///tmp/ecs-deploy-policy.json
13
+ aws iam get-role-policy --role-name codebuild-myapp-service-role --policy-name EcsDeployPolicy
14
+
15
+ The `put-role-policy` command adds a *inline* policy to the existing IAM role.
16
+
17
+ ## New IAM Role
18
+
19
+ If you are creating the IAM role for CodeBuild yourself from scratch these commands will be helpful:
20
+
21
+ Create the policy document:
22
+
23
+ cat << 'EOF' > /tmp/role-trust-policy.json
24
+ {
25
+ "Version": "2012-10-17",
26
+ "Statement": [{
27
+ "Action": "sts:AssumeRole",
28
+ "Principal": {
29
+ "Service": "codebuild.amazonaws.com"
30
+ },
31
+ "Effect": "Allow",
32
+ "Sid": ""
33
+ }]
34
+ }
35
+ EOF
36
+
37
+ Create the IAM resources:
38
+
39
+ aws iam create-role --role-name EcsDeployRole --assume-role-policy-document file:///tmp/role-trust-policy.json
40
+ aws iam create-policy --policy-name EcsDeployPolicy --policy-document file:///tmp/ecs-deploy-policy.json
41
+ ACCOUNT=$(aws sts get-caller-identity | jq -r '.Account')
42
+ aws iam attach-role-policy --policy-arn arn:aws:iam::$ACCOUNT:policy/EcsDeployPolicy --role-name EcsDeployRole
43
+
44
+ The `attach-role-policy` command attaches a Customer Managed IAM policy to the IAM role. This is a little more reusable than using an inline policy.
45
+
46
+ {% include prev_next.md %}
@@ -67,16 +67,13 @@ Then create a user and add the user to IAM group. Here's an example:
67
67
  aws iam create-user --user-name tung
68
68
  aws iam add-user-to-group --user-name tung --group-name Ufo
69
69
 
70
- ## CodeBuild
70
+ ## CodeBuild IAM Role
71
71
 
72
- If you're using CodeBuild with `ufo ship` to handle deployments, you can use the same policy for the role that you assign to the the CodeBuild project and attach it to the the CodeBuild service IAM role that is usually created with the CodeBuild Console wizard. For example, of the IAM role was called `codebuild-myapp-service-role`:
73
-
74
- aws iam put-role-policy --role-name codebuild-myapp-service-role --policy-name EcsDeployPolicy --policy-document file:///tmp/ecs-deploy-policy.json
75
- aws iam get-role-policy --role-name codebuild-myapp-service-role --policy-name EcsDeployPolicy
72
+ If you are using CodeBuild to deploy, you'll probably be interested the IAM policy for the CodeBuild project: [CodeBuild IAM Role]({% link _docs/extras/codebuild-iam-role.md %})
76
73
 
77
74
  ## ECS Task IAM Policy vs User Deploy IAM Policy
78
75
 
79
76
  This page refers to your **user** IAM policy used when running `ufo ship`. These are different from the IAM Policies associated with ECS Task. For those iam policies refer to [IAM Roles for Tasks
80
77
  ](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html).
81
78
 
82
- {% include prev_next.md %}
79
+ {% include prev_next.md %}
data/docs/_docs/faq.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: FAQ
3
- nav_order: 40
3
+ nav_order: 41
4
4
  ---
5
5
 
6
6
  **Q: Is AWS ECS Fargate supported?**
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Auto Completion
3
- nav_order: 39
3
+ nav_order: 40
4
4
  ---
5
5
 
6
6
  Ufo supports bash auto-completion. To set it up add the following to your `~/.profile` or `.bashrc`:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Automated Clean Up
3
- nav_order: 38
3
+ nav_order: 39
4
4
  ---
5
5
 
6
6
  Ufo can be configured to automatically clean old images from the ECR registry after the deploy completes by configuring your [settings.yml]({% link _docs/settings.md %}) file like so:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Customize CloudFormation
3
- nav_order: 33
3
+ nav_order: 34
4
4
  ---
5
5
 
6
6
  Under the hood, ufo creates most of the required resources with a CloudFormation stack. This includes the ELB, Target Group, Listener, Security Groups, ECS Service, and Route 53 records. You might need to customize these resources. Here are the ways to customize the resources that ufo creates.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Database Migrations
3
- nav_order: 37
3
+ nav_order: 38
4
4
  ---
5
5
 
6
6
  A common task is to run database migrations with newer code before deploying the code. This is easily achieved with the `ufo task` command. Here's an example:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Run in Pieces
3
- nav_order: 35
3
+ nav_order: 36
4
4
  ---
5
5
 
6
6
  The `ufo ship` command goes through a few stages:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Run Single Task
3
- nav_order: 36
3
+ nav_order: 37
4
4
  ---
5
5
 
6
6
  Sometimes you do not want to run a long running `service` but a one time task. Running Rails migrations are an example of a one off task. Here is an example of how you would run a one time task.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Stuck CloudFormation
3
- nav_order: 34
3
+ nav_order: 35
4
4
  ---
5
5
 
6
6
  The CloudFormation stack update or creation can get stuck in a `*_IN_PROGRESS` state for a very long time, like more than an hour. This happens when you deploy an ECS service that fails to stabilize. Usually, this is an error with the Docker container failing to start up successfully.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Why CloudFormation
3
- nav_order: 32
3
+ nav_order: 33
4
4
  ---
5
5
 
6
6
  Version 3 of ufo was a simpler implementation and did not make use of CloudFormation to create the ECS service. In version 4, ufo uses CloudFormation to create the ECS Service. This is because ufo became more powerful. Notably, support for Load Balancers was added. With this power, also came added complexity. So the complexity was push onto CloudFormation. Hence, ECS service is implemented as CloudFormation resource in version 4.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Next Steps
3
- nav_order: 42
3
+ nav_order: 43
4
4
  ---
5
5
 
6
6
  This concludes the tutorial guide for ufo. Hopefully you are now more comfortable with ufo's basic usage, concepts, and have a feel for the workflow.
@@ -9,12 +9,14 @@ ECS EC2 is a way to run Docker containers on your own EC2 instances. This diffe
9
9
 
10
10
  ## Let's Go
11
11
 
12
- In a hurry? No sweat! Here's a quick start to using ufo that takes only a few minutes. For this example, we will use a Sinatra app from [tongueroo/demo-ufo](https://github.com/tongueroo/demo-ufo). The `ufo init` command sets up the ufo directory structure in your project. The `ufo ship` command deploys your code to an AWS ECS service. The `ufo ps` and `ufo scale` command shows you how to verify and scale additional containers.
12
+ In a hurry? No sweat! Here's a quick start to using ufo that takes only a few minutes. For this example, we will use a Sinatra app from [tongueroo/demo-ufo](https://github.com/tongueroo/demo-ufo). The `ufo init` command sets up the ufo directory structure in your project. The `ufo ship` command deploys your code to an AWS ECS service. The `ufo ps` and `ufo scale` command shows you how to verify and scale additional containers.
13
13
 
14
14
  gem install ufo
15
15
  git clone https://github.com/tongueroo/demo-ufo.git demo
16
16
  cd demo
17
- ufo init --image=tongueroo/demo-ufo # NOTE: use your own account
17
+ aws ecr create-repository --repository-name demo/sinatra
18
+ ECR_REPO=$(aws ecr describe-repositories --repository-name demo/sinatra | jq -r '.repositories[].repositoryUri')
19
+ ufo init --image $ECR_REPO
18
20
  ufo current --service demo-web
19
21
  ufo ship
20
22
  ufo ps
@@ -22,7 +24,7 @@ In a hurry? No sweat! Here's a quick start to using ufo that takes only a few mi
22
24
 
23
25
  This quickstart assumes:
24
26
 
25
- * You have push access to the repo. Refer to the Notes "Repo Push Access" section below for more info.
27
+ * You have push access to the repo. Refer to the Notes "Repo Push Access" section below for more info.
26
28
  * You are using ECS EC2 and have an ECS cluster with EC2 Container instances running. Refer to the Notes "ECS EC2 vs ECS Fargate" section below for more info.
27
29
 
28
30
  ## What Happened
@@ -52,7 +54,7 @@ Setting up ufo project...
52
54
  Starter ufo files created.
53
55
  $ ufo ship demo-web
54
56
  Building docker image with:
55
- docker build -t tongueroo/demo-ufo:ufo-2017-09-10T15-00-19-c781aaf -f Dockerfile .
57
+ docker build -t 112233445566.dkr.ecr.us-west-2.amazonaws.com/demo/sinatra:ufo-2017-09-10T15-00-19-c781aaf -f Dockerfile .
56
58
  ....
57
59
  Software shipped!
58
60
  $ ufo ps
@@ -3,7 +3,7 @@ title: Upgrading to Version 4.4
3
3
  short_title: Version 4.4
4
4
  order: 1
5
5
  categories: upgrading
6
- nav_order: 30
6
+ nav_order: 31
7
7
  ---
8
8
 
9
9
  In ufo version 4.4, the environment name gets appends to the end of the CloudFormation stack name. Previous versions prepended the environment name to the stack name. This means a new stack gets created if you're going from version 4.3 to 4.4. For example:
@@ -3,7 +3,7 @@ title: Upgrading to Version 4.0
3
3
  short_title: Version 4.0
4
4
  order: 2
5
5
  categories: upgrading
6
- nav_order: 31
6
+ nav_order: 32
7
7
  ---
8
8
 
9
9
  A major change in ufo from version 3 to 4 is that the ECS service is now created by CloudFormation. If you have an existing ECS service deployed by ufo version 3, when you deploy your app again with ufo version 4, there will be a new additional ECS service created. Here is the recommended upgrade path.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Upgrading
3
- nav_order: 29
3
+ nav_order: 30
4
4
  ---
5
5
 
6
6
  <ul>
@@ -1,8 +1,8 @@
1
1
  ## Repo Push Access
2
2
 
3
- The quick start example pushes the Docker image to a Dockerhub repo. You need your own repo with push access. This repo could be your own Dockerhub account or ECR repo. You can control the setting with the `--image` option. Example:
3
+ The quick start example pushes the Docker image to a Docker repo that you have access to. This repo could be your own Dockerhub account or ECR repo. You can control the setting with the `--image` option. Example:
4
4
 
5
- ufo init --image=yourusername/yourrepo # use your own account
5
+ ufo init --image=yourusername/yourrepo # use your own Dockerhub account
6
6
 
7
7
  Also, if you are using ECR instead, you can specify an ECR repo with the `--image` option. Example:
8
8
 
@@ -34,6 +34,7 @@
34
34
  <li><a href="{% link _docs/extras/route53-support.md %}">Route53 Support</a></li>
35
35
  <li><a href="{% link _docs/extras/redirection-support.md %}">Redirection Support</a></li>
36
36
  <li><a href="{% link _docs/extras/minimal-deploy-iam.md %}">Minimal Deploy IAM</a></li>
37
+ <li><a href="{% link _docs/extras/codebuild-iam-role.md %}">CodeBuild IAM Role</a></li>
37
38
  </ul>
38
39
  <li><a href="{% link _docs/upgrading.md %}">Upgrading</a>
39
40
  <ul>
data/docs/articles.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Articles
3
- nav_order: 41
3
+ nav_order: 42
4
4
  ---
5
5
 
6
6
  * [How to Create Unlimited Extra Environments
data/docs/quick-start.md CHANGED
@@ -14,7 +14,9 @@ In a hurry? No sweat! Here's a quick start to using ufo that takes only a few mi
14
14
  git clone https://github.com/tongueroo/demo-ufo demo
15
15
  cd demo
16
16
  AWS_ACCOUNT=$(aws sts get-caller-identity | jq -r '.Account')
17
- ufo init --image tongueroo/demo-ufo --launch-type fargate --execution-role-arn arn:aws:iam::$AWS_ACCOUNT:role/ecsTaskExecutionRole
17
+ aws ecr create-repository --repository-name demo/sinatra
18
+ ECR_REPO=$(aws ecr describe-repositories --repository-name demo/sinatra | jq -r '.repositories[].repositoryUri')
19
+ ufo init --image $ECR_REPO --launch-type fargate --execution-role-arn arn:aws:iam::$AWS_ACCOUNT:role/ecsTaskExecutionRole
18
20
  ufo current --service demo-web
19
21
  ufo ship
20
22
  ufo ps
@@ -22,7 +24,7 @@ In a hurry? No sweat! Here's a quick start to using ufo that takes only a few mi
22
24
 
23
25
  This quickstart assumes:
24
26
 
25
- * You have push access to the repo. Refer to the Notes "Repo Push Access" section below for more info.
27
+ * You have push access to the repo. Refer to the Notes "Repo Push Access" section below for more info.
26
28
  * The `ecsTaskExecutionRole` needs to exist on your AWS account. If you do not have an ecsTaskExecutionRole yet, create one by following: [Create ecsTaskExecutionRole with AWS CLI]({% link _docs/aws-ecs-task-execution-role.md %}).
27
29
 
28
30
  ## What Happened
@@ -38,7 +40,7 @@ You should see output similar to this.
38
40
 
39
41
  $ ufo ship
40
42
  Building docker image with:
41
- docker build -t tongueroo/demo-ufo:ufo-2018-06-29T22-54-07-20b3a10 -f Dockerfile .
43
+ docker build -t 112233445566.dkr.ecr.us-west-2.amazonaws.com/demo/sinatra:ufo-2018-06-29T22-54-07-20b3a10 -f Dockerfile .
42
44
  ...
43
45
  10:58:38PM CREATE_COMPLETE AWS::ECS::Service Ecs
44
46
  10:58:40PM CREATE_COMPLETE AWS::CloudFormation::Stack development-demo-web
data/lib/cfn/stack.yml CHANGED
@@ -101,9 +101,10 @@ Resources:
101
101
  # When adding and removing EIPs
102
102
  # Error: TargetGroup cannot be associated with more than one load balancer
103
103
  # Solution: https://forums.aws.amazon.com/thread.jspa?threadID=254544
104
+ # Note: we truncate the stack name because target group names can be only 32 chars long
104
105
  Name: !Join
105
106
  - '-'
106
- - - <%= @stack_name %>
107
+ - - <%= @stack_name[0..-6] %>
107
108
  - !Select [ 2, !Split [ '-', !GetAtt Elb.LoadBalancerName]]
108
109
  <% end -%>
109
110
  Protocol: <%= @default_target_group_protocol %>
@@ -9,7 +9,7 @@ class Ufo::Network
9
9
  fetch = Fetch.new(@options[:vpc_id])
10
10
  @options[:vpc_id] ||= fetch.vpc_id
11
11
  @options[:ecs_subnets] ||= fetch.subnet_ids
12
- @options[:elb_subnets] ||= fetch.subnet_ids
12
+ @options[:elb_subnets] ||= @options[:ecs_subnets] || fetch.subnet_ids
13
13
  end
14
14
 
15
15
  # hack for specs
data/lib/ufo/network.rb CHANGED
@@ -7,7 +7,8 @@ module Ufo
7
7
  def self.cli_options
8
8
  [
9
9
  [:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."],
10
- [:subnets, type: :array, desc: "Subnets"],
10
+ [:ecs_subnets, type: :array, desc: "ECS Subnets"],
11
+ [:elb_subnets, type: :array, desc: "ELB Subnets"],
11
12
  [:vpc_id, desc: "Vpc id"],
12
13
  [:filename, default: "default", desc: "Name of the settings file to create w/o extension."],
13
14
  ]
data/lib/ufo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ufo
2
- VERSION = "4.4.2"
2
+ VERSION = "4.4.3"
3
3
  end
data/lib/ufo.rb CHANGED
@@ -1,3 +1,5 @@
1
+ $stdout.sync = true unless ENV["UFO_STDOUT_SYNC"] == "0"
2
+
1
3
  $:.unshift(File.expand_path('../', __FILE__))
2
4
  require 'deep_merge'
3
5
  require 'fileutils'
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: 4.4.2
4
+ version: 4.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-24 00:00:00.000000000 Z
11
+ date: 2019-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-cloudformation
@@ -292,6 +292,7 @@ files:
292
292
  - docs/_config.yml
293
293
  - docs/_docs/aws-ecs-task-execution-role.md
294
294
  - docs/_docs/conventions.md
295
+ - docs/_docs/extras/codebuild-iam-role.md
295
296
  - docs/_docs/extras/ecs-network-mode.md
296
297
  - docs/_docs/extras/load-balancer.md
297
298
  - docs/_docs/extras/minimal-deploy-iam.md