ufo 4.5.11 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/README.md +2 -0
  4. data/docs/_docs/conventions.md +1 -1
  5. data/docs/_docs/extras/codebuild-iam-role.md +2 -2
  6. data/docs/_docs/extras/dockerfile-erb.md +2 -2
  7. data/docs/_docs/extras/ecs-network-mode.md +2 -2
  8. data/docs/_docs/extras/load-balancer.md +2 -2
  9. data/docs/_docs/extras/minimal-deploy-iam.md +2 -2
  10. data/docs/_docs/extras/notification-arns.md +21 -0
  11. data/docs/_docs/extras/redirection-support.md +2 -2
  12. data/docs/_docs/extras/route53-support.md +2 -2
  13. data/docs/_docs/extras/security-groups.md +2 -2
  14. data/docs/_docs/extras/ssl-support.md +2 -2
  15. data/docs/_docs/faq.md +2 -2
  16. data/docs/_docs/helpers.md +7 -5
  17. data/docs/_docs/iam-roles.md +111 -0
  18. data/docs/_docs/install.md +1 -1
  19. data/docs/_docs/more/auto-completion.md +2 -2
  20. data/docs/_docs/more/automated-cleanup.md +2 -2
  21. data/docs/_docs/more/customize-cloudformation.md +2 -2
  22. data/docs/_docs/more/migrations.md +2 -2
  23. data/docs/_docs/more/run-in-pieces.md +2 -2
  24. data/docs/_docs/more/single-task.md +2 -2
  25. data/docs/_docs/more/stuck-cloudformation.md +2 -2
  26. data/docs/_docs/more/why-cloudformation.md +2 -2
  27. data/docs/_docs/next-steps.md +2 -2
  28. data/docs/_docs/quick-start-ec2.md +2 -1
  29. data/docs/_docs/secrets.md +112 -0
  30. data/docs/_docs/settings.md +1 -1
  31. data/docs/_docs/settings/aws_profile.md +1 -1
  32. data/docs/_docs/settings/cfn.md +1 -1
  33. data/docs/_docs/settings/cluster.md +8 -14
  34. data/docs/_docs/settings/network.md +1 -1
  35. data/docs/_docs/ssl_errors.md +1 -2
  36. data/docs/_docs/structure.md +1 -1
  37. data/docs/_docs/tutorial-ufo-docker-build.md +1 -1
  38. data/docs/_docs/tutorial-ufo-init.md +1 -1
  39. data/docs/_docs/tutorial-ufo-ship.md +1 -1
  40. data/docs/_docs/tutorial-ufo-ships.md +1 -1
  41. data/docs/_docs/tutorial-ufo-tasks-build.md +1 -1
  42. data/docs/_docs/tutorial.md +1 -1
  43. data/docs/_docs/ufo-current.md +2 -2
  44. data/docs/_docs/ufo-env-extra.md +2 -2
  45. data/docs/_docs/ufo-env.md +2 -2
  46. data/docs/_docs/ufo-logs.md +50 -0
  47. data/docs/_docs/ufo-task-params.md +2 -2
  48. data/docs/_docs/upgrading.md +2 -2
  49. data/docs/_docs/upgrading/upgrade4.5.md +2 -2
  50. data/docs/_docs/upgrading/upgrade4.md +2 -2
  51. data/docs/_docs/variables.md +1 -1
  52. data/docs/_includes/subnav.html +4 -0
  53. data/docs/_reference/ufo-deploy.md +1 -2
  54. data/docs/_reference/ufo-init.md +1 -1
  55. data/docs/_reference/ufo-logs.md +40 -0
  56. data/docs/_reference/ufo-rollback.md +2 -0
  57. data/docs/_reference/ufo-ship.md +1 -2
  58. data/docs/_reference/ufo-ships.md +1 -2
  59. data/docs/_reference/ufo-tasks-build.md +1 -2
  60. data/docs/articles.md +2 -2
  61. data/docs/docs.md +1 -1
  62. data/docs/quick-start.md +2 -1
  63. data/docs/reference.md +1 -0
  64. data/lib/template/.secrets +3 -0
  65. data/lib/template/.ufo/settings.yml.tt +1 -0
  66. data/lib/template/.ufo/settings/cfn/default.yml.tt +27 -27
  67. data/lib/template/.ufo/settings/network/default.yml.tt +9 -0
  68. data/lib/template/.ufo/templates/fargate.json.erb +3 -0
  69. data/lib/template/.ufo/templates/main.json.erb +3 -0
  70. data/lib/template/.ufo/variables/base.rb.tt +1 -0
  71. data/lib/ufo.rb +2 -1
  72. data/lib/ufo/autoloader.rb +9 -0
  73. data/lib/ufo/cli.rb +12 -1
  74. data/lib/ufo/command.rb +7 -0
  75. data/lib/ufo/core.rb +1 -9
  76. data/lib/ufo/docker/cleaner.rb +1 -1
  77. data/lib/ufo/dsl.rb +6 -1
  78. data/lib/ufo/dsl/helper.rb +21 -27
  79. data/lib/ufo/dsl/helper/vars.rb +98 -0
  80. data/lib/ufo/dsl/outputter.rb +12 -9
  81. data/lib/ufo/help/init.md +1 -1
  82. data/lib/ufo/help/logs.md +10 -0
  83. data/lib/ufo/log_group.rb +1 -0
  84. data/lib/ufo/logs.rb +56 -0
  85. data/lib/ufo/role/builder.rb +66 -0
  86. data/lib/ufo/role/dsl.rb +21 -0
  87. data/lib/ufo/role/registry.rb +24 -0
  88. data/lib/ufo/rollback.rb +2 -1
  89. data/lib/ufo/setting/profile.rb +11 -7
  90. data/lib/ufo/setting/security_groups.rb +22 -0
  91. data/lib/ufo/settings.rb +20 -0
  92. data/lib/ufo/stack.rb +24 -24
  93. data/lib/ufo/stack/builder.rb +26 -0
  94. data/lib/ufo/stack/builder/base.rb +54 -0
  95. data/lib/ufo/stack/builder/conditions.rb +23 -0
  96. data/lib/ufo/stack/builder/outputs.rb +24 -0
  97. data/lib/ufo/stack/builder/parameters.rb +45 -0
  98. data/lib/ufo/stack/builder/resources.rb +20 -0
  99. data/lib/ufo/stack/builder/resources/base.rb +4 -0
  100. data/lib/ufo/stack/builder/resources/dns.rb +17 -0
  101. data/lib/ufo/stack/builder/resources/ecs.rb +63 -0
  102. data/lib/ufo/stack/builder/resources/elb.rb +45 -0
  103. data/lib/ufo/stack/builder/resources/listener.rb +42 -0
  104. data/lib/ufo/stack/builder/resources/listener_ssl.rb +16 -0
  105. data/lib/ufo/stack/builder/resources/roles/base.rb +22 -0
  106. data/lib/ufo/stack/builder/resources/roles/execution_role.rb +4 -0
  107. data/lib/ufo/stack/builder/resources/roles/task_role.rb +4 -0
  108. data/lib/ufo/stack/builder/resources/security_group/base.rb +4 -0
  109. data/lib/ufo/stack/builder/resources/security_group/ecs.rb +44 -0
  110. data/lib/ufo/stack/builder/resources/security_group/ecs_rule.rb +25 -0
  111. data/lib/ufo/stack/builder/resources/security_group/elb.rb +57 -0
  112. data/lib/ufo/stack/builder/resources/target_group.rb +39 -0
  113. data/lib/ufo/stack/builder/resources/task_definition.rb +24 -0
  114. data/lib/ufo/stack/builder/resources/task_definition/reconstructor.rb +49 -0
  115. data/lib/ufo/stack/context.rb +41 -48
  116. data/lib/ufo/stack/custom_properties.rb +59 -0
  117. data/lib/ufo/stack/helper.rb +2 -5
  118. data/lib/ufo/stack/template_body.rb +13 -0
  119. data/lib/ufo/task.rb +2 -7
  120. data/lib/ufo/tasks.rb +1 -1
  121. data/lib/ufo/tasks/builder.rb +0 -1
  122. data/lib/ufo/tasks/register.rb +11 -8
  123. data/lib/ufo/template_scope.rb +1 -66
  124. data/lib/ufo/utils/squeezer.rb +24 -0
  125. data/lib/ufo/version.rb +1 -1
  126. data/spec/fixtures/iam_roles/task_role.rb +17 -0
  127. data/spec/fixtures/mocks/logs/awslogs.json +70 -0
  128. data/spec/fixtures/mocks/logs/no-awslogs.json +70 -0
  129. data/spec/lib/logs_spec.rb +55 -0
  130. data/spec/lib/role/builder_spec.rb +67 -0
  131. data/spec/lib/role/dsl_spec.rb +12 -0
  132. data/ufo.gemspec +2 -0
  133. metadata +82 -5
  134. data/lib/cfn/stack.yml +0 -283
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a7401ccc5d5e288b485c4eaaf21a4ae14864a23bdc52c4e36ce9bf060f35d55
4
- data.tar.gz: 2528b31c9fea0c43785a2d1c17c2529c85f3ac85dd431e9cc5de7fbca28cdc53
3
+ metadata.gz: ce5c8180b261636a61805a4abc5cbd3d556784f77dbf20ca0f2384d8ab50ae32
4
+ data.tar.gz: 9d6e1955bd7ca4b35b347c61986af5c92c916410a1d9b43b0d11a76e1dbd4fc3
5
5
  SHA512:
6
- metadata.gz: 890ed4c9715cea6d1c6865e13a3895467d72e266363ea0647111e513299c1e4d3182d68ad8039212bbae2d6c59d16ab53d44629042cde185a173c4fa62f3fbe4
7
- data.tar.gz: bb31a72b778cb39de850a07cb6ce94dc31c50b2f257d067c77b5fa40dcf5d1dfcc3ce50d05c9980e8a1fa298c4f229bb1d47c6df0d44ae18e24d0b218f1647fc
6
+ metadata.gz: 60ec0e82534f94e8daffbb9587f22753e4df92a77545ba4f220e0f9f3f1568a7dc0722f32e278f1853160ab477e80b0cfef8dbde6330c0b0af46a3e4695c8bc6
7
+ data.tar.gz: 4bb7540d47f271ea211b3ade315b6a69fe9d1ce23b2cf0cef82cf2ddb1905d849a6064a08aab07279e623073f985542f8396533aedde86fc0b78a39e99ca8bb0
@@ -3,6 +3,35 @@
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
+ ## [5.0.0]
7
+ - #104 adjust logs default format to detailed
8
+ - #105 major rework: build cfn template with Ruby instead of ERB for new features
9
+ - #106 secrets support
10
+ - Codified iam_role support with .ufo/iam_roles files: custom and managed policy support. The ECS Task definition was moved into CloudFormation to support this.
11
+ - Allow per service security groups
12
+ - Conventional .ufo/settings cfn and network files based on ufo env
13
+ - Managed_security_groups_enabled=false setting.yml
14
+ - Project custom helper methods support
15
+ - Add image-override option for ufo ship
16
+ - Notification ARN stack cloudformation support for compliance reasons
17
+ - update cfn/default to use CamelCase. maintain backward compatibility with underscore. through encourage users to upgrade to CamelCase. There's less mental translation overhead.
18
+ - remove pretty option: always pretty
19
+
20
+ ## [4.6.3]
21
+ - #101 improve ufo init help
22
+
23
+ ## [4.6.2]
24
+ - define texit_on_failure to remove Thor deprecation warning
25
+
26
+ ## [4.6.1]
27
+ - #93 Fix firelens functionality
28
+ - #97 ufo logs --filter-pattern option
29
+ - #98 fix env vars helper to allow surrounding quotes
30
+
31
+ ## [4.6.0]
32
+ - #95 Introduce: ufo logs command. Tail logs.
33
+ - #96 docs and options
34
+
6
35
  ## [4.5.11]
7
36
  - add mfa support for normal IAM user
8
37
 
data/README.md CHANGED
@@ -8,6 +8,8 @@
8
8
  [![Join the chat at https://gitter.im/tongueroo/ufo](https://badges.gitter.im/tongueroo/ufo.svg)](https://gitter.im/tongueroo/ufo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
9
9
  [![Support](https://img.shields.io/badge/get-support-blue.svg)](https://boltops.com?utm_source=badge&utm_medium=badge&utm_campaign=ufo)
10
10
 
11
+ [![BoltOps Badge](https://img.boltops.com/boltops/badges/boltops-badge.png)](https://www.boltops.com)
12
+
11
13
  Ufo is a tool that builds Docker images and deploys them to [AWS ECS](https://aws.amazon.com/ecs/). The main command is `ufo ship`. Here's summary of what it does:
12
14
 
13
15
  1. Builds a docker image.
@@ -44,4 +44,4 @@ You can also use an existing ELB by specifying the target group arn as the value
44
44
  ufo ship demo-web --elb arn:aws:elasticloadbalancing:us-east-1:12345689:targetgroup/demo-web/12345
45
45
  ```
46
46
 
47
- {% include prev_next.md %}
47
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: CodeBuild IAM Role
3
- nav_order: 31
3
+ nav_order: 32
4
4
  ---
5
5
 
6
6
  Note, the `/tmp/ecs-deploy-policy.json` policy is available at [Minimal Deploy IAM]({% link _docs/extras/minimal-deploy-iam.md %}).
@@ -43,4 +43,4 @@ Create the IAM resources:
43
43
 
44
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
45
 
46
- {% include prev_next.md %}
46
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Dynamic Dockerfile.erb
3
- nav_order: 32
3
+ nav_order: 33
4
4
  ---
5
5
 
6
6
  Sometimes you may need a little more dynamic control of your Dockerfile. For these cases, ufo supports dynamically creating a Dockerfile from a Dockerfile.erb. If Dockerfile.erb exists, ufo uses it to generate a Dockerfile as a part of the build process. These means that you should update the source Dockerfile.erb instead, as the Dockerfile will be overwritten. If Dockerfile.erb does not exist, then ufo will use the Dockerfile instead.
@@ -57,4 +57,4 @@ Why not use [build args](https://www.jeffgeerling.com/blog/2017/use-arg-dockerfi
57
57
 
58
58
  Ufo uses a YAML file so users will not have to remember to provide the build arg. It is also easy to update the `dockerfile_variables.yml` with the `ufo docker base` command.
59
59
 
60
- {% include prev_next.md %}
60
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: ECS Network Mode
3
- nav_order: 26
3
+ nav_order: 27
4
4
  ---
5
5
 
6
6
  ## Pros and Cons: bridge network mode
@@ -34,4 +34,4 @@ awsvpc | Fine grain security group permissions for each ECS service. | The numbe
34
34
 
35
35
  It is generally recommended to use awsvpc mode with ENI trunking supported instances. You get the best of both worlds in this situation: a strong security posture as well as container density.
36
36
 
37
- {% include prev_next.md %}
37
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Load Balancer Support
3
- nav_order: 24
3
+ nav_order: 25
4
4
  ---
5
5
 
6
6
  Ufo can automatically create a load balancer and associate it with an ECS service. The options:
@@ -80,4 +80,4 @@ Under the hood, ufo implements load balancer support with CloudFormation. You ca
80
80
 
81
81
  <img src="/img/docs/cloudformation-resources.png" class="doc-photo" />
82
82
 
83
- {% include prev_next.md %}
83
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Minimal Deploy IAM Policy
3
- nav_order: 30
3
+ nav_order: 31
4
4
  ---
5
5
 
6
6
  The IAM user you use to run the `ufo ship` command needs a minimal set of IAM policies in order to deploy to ECS. Here is a table of the baseline services needed:
@@ -76,4 +76,4 @@ If you are using CodeBuild to deploy, you'll probably be interested the IAM poli
76
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
77
77
  ](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html).
78
78
 
79
- {% include prev_next.md %}
79
+ {% include prev_next.md %}
@@ -0,0 +1,21 @@
1
+ ---
2
+ title: Notification ARNs
3
+ categories: extras
4
+ nav_order: 99
5
+ ---
6
+
7
+ You can specific notification arns for CloudFormation stack related events with [configs/settings.yml]({% link _docs/settings.md %}). This may be useful for compliance purposes.
8
+
9
+ ## Example
10
+
11
+ configs/settings.yml
12
+
13
+ ```yaml
14
+ base:
15
+ notification_arns:
16
+ - arn:aws:sns:us-west-2:112233445566:my-sns-topic1
17
+ ```
18
+
19
+ This will set the `notification_arns` option as the CloudFormation stack created by `ufo ship`.
20
+
21
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Redirection Support
3
- nav_order: 29
3
+ nav_order: 30
4
4
  ---
5
5
 
6
6
  ## Application Load Balancers
@@ -24,4 +24,4 @@ listener:
24
24
 
25
25
  Network Load Balancers work at layer 4, so they do not support redirection. Instead you need to handle redirection within your app.
26
26
 
27
- {% include prev_next.md %}
27
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Route53 Support
3
- nav_order: 28
3
+ nav_order: 29
4
4
  ---
5
5
 
6
6
  Ufo can create a "pretty" route53 record and set it's value to the created ELB DNS name. This is done by configuring the `.ufo/settings/cfn/default.yml` file. Example:
@@ -24,4 +24,4 @@ Results in:
24
24
  aws route53 create-hosted-zone --name mydomain.com --caller-reference $(date +%s)
25
25
  aws route53 list-hosted-zones
26
26
 
27
- {% include prev_next.md %}
27
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Security Groups
3
- nav_order: 25
3
+ nav_order: 26
4
4
  ---
5
5
 
6
6
  Ufo creates and manages two security groups. One for the ELB and one for the ECS tasks.
@@ -33,4 +33,4 @@ In general, ports below 32768 are outside of the ephemeral port range. So an eas
33
33
 
34
34
  If you are using a network load balancer and are running bridge network mode, then you need to whitelist ports 32768 to 65535 to `0.0.0.0/0`. This is because network load balancers operate at layer 4 of the OSI model and cannot be assigned security groups, so they use the security group of the instance. If you feel this is too loose of permissions, you can use awsvpc mode. There are some considerations for awsvpc mode though which is discussed next.
35
35
 
36
- {% include prev_next.md %}
36
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: SSL Support
3
- nav_order: 27
3
+ nav_order: 28
4
4
  ---
5
5
 
6
6
  You can configure SSL support by uncomment the `listener_ssl` option in `.ufo/settings/cfn/default.yml`. Here's an example:
@@ -17,4 +17,4 @@ For the certificate arn, you will need to create a certificate with AWS ACM. To
17
17
 
18
18
  The protocol will be either HTTP or HTTPS for Application Load Balancers and TCP or TLS for Network Load Balancers. Ufo will infer the right value, so you usually don't have to configure the protocol manually. You can configure it if required though.
19
19
 
20
- {% include prev_next.md %}
20
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: FAQ
3
- nav_order: 44
3
+ nav_order: 45
4
4
  ---
5
5
 
6
6
  **Q: Is AWS ECS Fargate supported?**
@@ -97,4 +97,4 @@ Also, you might have to enable the log driver by adding the ECS_AVAILABLE_LOGGIN
97
97
 
98
98
  Hope that helps.
99
99
 
100
- {% include prev_next.md %}
100
+ {% include prev_next.md %}
@@ -9,14 +9,16 @@ For example, one of the helper methods provides the exposed port in the Dockerfi
9
9
 
10
10
  Helper | Description
11
11
  ------------- | -------------
12
- full\_image\_name| The full docker image name that ufo builds. The "base" portion of the docker image name is defined in `settings.yml`. For example, the base portion is `tongueroo/demo-ufo` and the full image name is `tongueroo/demo-ufo:ufo-[timestamp]-[sha]`. The base name does not include the generated Docker tag, which contains a timestamp and git sha of the project.
13
- dockerfile\_port| Exposed port extracted from the Dockerfile of the project. 
14
- env_vars(text)| This method takes a block of text that contains the env values in `key=value` format and converts that block of text to the proper task definition JSON format.
15
- env_file(path)| This method takes a `.env` file which contains a simple key-value list of environment variables and converts the list to the proper task definition JSON format.
12
+ full\_image\_name | The full docker image name that ufo builds. The "base" portion of the docker image name is defined in `settings.yml`. For example, the base portion is `tongueroo/demo-ufo` and the full image name is `tongueroo/demo-ufo:ufo-[timestamp]-[sha]`. The base name does not include the generated Docker tag, which contains a timestamp and git sha of the project.
13
+ dockerfile\_port | Exposed port extracted from the Dockerfile of the project.
14
+ env_vars(text) | This method takes a block of text that contains the env values in `key=value` format and converts that block of text to the proper task definition JSON format.
15
+ env_file(path) | This method takes a `.env` file which contains a simple key-value list of environment variables and converts the list to the proper task definition JSON format.
16
+ secrets_vars(text) | This method takes a block of text that contains the secrets values in `key=value` format and converts that block of text to the proper task definition JSON format.
17
+ secrets_file(path) | This method takes a `.secrets` file which contains a simple key-value list of environment variables and converts the list to the proper task definition JSON format.
16
18
  task_definition_name | The name of the task_definition. So if the code looks like this `task_definition "demo-web" do`, the task_definition_name is "demo-web".
17
19
 
18
20
  To call the helper in task_definitions.rb you must add `helper.` in front. So `full_image_name` is called via `helper.full_image_name`.
19
21
 
20
22
  The 2 classes which provide these special helper methods are in [ufo/dsl.rb](https://github.com/tongueroo/ufo/blob/master/lib/ufo/dsl.rb) and [ufo/dsl/helper.rb](https://github.com/tongueroo/ufo/blob/master/lib/ufo/dsl/helper.rb). Refer to these classes for the full list of the helper methods.
21
23
 
22
- {% include prev_next.md %}
24
+ {% include prev_next.md %}
@@ -0,0 +1,111 @@
1
+ ---
2
+ title: Task Definition IAM Roles
3
+ ---
4
+
5
+ ## What are ECS IAM Roles?
6
+
7
+ For ECS Task Definitions, you can assign it 2 IAM roles: 1) taskRoleArn and 2) executionRoleArn. It's usually defined in the JSON structure like so:
8
+
9
+ ```json
10
+ {
11
+ "family": "..",
12
+ "taskRoleArn": "...",
13
+ "executionRoleArn": "...",
14
+ "containerDefinitions": [
15
+ ...
16
+ ]
17
+ }
18
+ ```
19
+
20
+ Here's a table that explains the difference between the 2 IAM roles.
21
+
22
+ Name | Purpose
23
+ --- | ---
24
+ taskRoleArn | This is the role that the ECS task itself uses. So this is what IAM permissions your application has access to. Think about it as the "container role".
25
+ executionRoleArn | This is the role that the EC2 instance host uses. This allows the EC2 instance to pull from the ECR registry. Think about it as the "host role".
26
+
27
+ ## How to Assign IAM Roles with UFO
28
+
29
+ You can assign an IAM role to the ECS Task definition in ways:
30
+
31
+ 1. IAM Role with Code (UFO Managed)
32
+ 2. Precreated IAM Role
33
+
34
+ ## IAM Role with Code (UFO Managed)
35
+
36
+ UFO can automatically create the IAM and assign it to the task definition. You create these files so UFO will know to create and manage the IAM roles.
37
+
38
+ .ufo/iam_roles/execution_role.rb
39
+ .ufo/iam_roles/task_role.rb
40
+
41
+ ### Example 1
42
+
43
+ You then use a DSL to create the IAM roles. Here are examples:
44
+
45
+ .ufo/iam_roles/execution_role.rb
46
+
47
+ ```ruby
48
+ managed_iam_policy("AmazonEC2ContainerRegistryReadOnly")
49
+ managed_iam_policy("AmazonSSMReadOnlyAccess")
50
+ managed_iam_policy("CloudWatchLogsFullAccess")
51
+ managed_iam_policy("SecretsManagerReadWrite")
52
+ managed_iam_policy("service-role/AmazonECSTaskExecutionRolePolicy")
53
+ ```
54
+
55
+ .ufo/iam_roles/task_role.rb
56
+
57
+ ```ruby
58
+ iam_policy("AmazonS3ReadOnlyAccess",
59
+ Action: [
60
+ "s3:Get*",
61
+ "s3:List*"
62
+ ],
63
+ Effect: "Allow",
64
+ Resource: "*"
65
+ )
66
+ iam_policy("CloudwatchWrite",
67
+ Action: [
68
+ "cloudwatch:PutMetricData",
69
+ ],
70
+ Effect: "Allow",
71
+ Resource: "*"
72
+ )
73
+ ```
74
+
75
+ ### Example 2
76
+
77
+ You can use the `managed_iam_policy` and `iam_policy` together. You can also group multiple statements in the `iam_policy` declaration.
78
+
79
+ .ufo/iam_roles/task_role.rb
80
+
81
+ ```ruby
82
+ managed_iam_policy("AmazonSSMManagedInstanceCore")
83
+
84
+ iam_policy("custom-policy", [
85
+ {
86
+ Action: "ecs:UpdateContainerInstancesState",
87
+ Resource: "*",
88
+ Effect: "Allow"
89
+ },
90
+ {
91
+ Action: "sns:Publish",
92
+ Resource: "*",
93
+ Effect: "Allow"
94
+ }
95
+ ])
96
+ ```
97
+
98
+ ## Pre-Created IAM Role
99
+
100
+ You can also assign the task definition `executionRoleArn` with pre-created IAM roles. It looks something like this in the `.ufo/templates/main.json.erb` file:
101
+
102
+ ```json
103
+ {
104
+ "family": "<%= @family %>",
105
+ "taskRoleArn": "arn:aws:iam::112233445566:role/pre-created-iam-role",
106
+ "executionRoleArn": "arn:aws:iam::112233445566:role/pre-created-iam-role",
107
+ "containerDefinitions": [
108
+ ...
109
+ ]
110
+ }
111
+ ```
@@ -32,4 +32,4 @@ For more information about the Bolts Toolbelt or to get an installer for another
32
32
  * Docker: You will need a working version of [Docker](https://docs.docker.com/engine/installation/) installed as ufo shells out and calls the `docker` command.
33
33
  * AWS: Set up your AWS credentials at `~/.aws/credentials` and `~/.aws/config`. This is the [AWS standard way of setting up credentials](https://aws.amazon.com/blogs/security/a-new-and-standardized-way-to-manage-credentials-in-the-aws-sdks/).
34
34
 
35
- {% include prev_next.md %}
35
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Auto Completion
3
- nav_order: 43
3
+ nav_order: 44
4
4
  ---
5
5
 
6
6
  Ufo supports bash auto-completion. To set it up add the following to your `~/.profile` or `.bashrc`:
@@ -21,4 +21,4 @@ Auto Completion examples:
21
21
  ufo tasks [TAB]
22
22
  ufo tasks build [TAB]
23
23
 
24
- {% include prev_next.md %}
24
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Automated Clean Up
3
- nav_order: 42
3
+ nav_order: 43
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:
@@ -11,4 +11,4 @@ ecr_keep: 30
11
11
 
12
12
  Automated Docker images clean up only works if you are using ECR registry.
13
13
 
14
- {% include prev_next.md %}
14
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Customize CloudFormation
3
- nav_order: 37
3
+ nav_order: 38
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.
@@ -32,4 +32,4 @@ UFO_ENV_EXTRA=2 ufo ship demo-web -\-cluster dev | demo-web-development-2
32
32
 
33
33
  The CloudFormation stack is currently generated from a template. The source code for this template is located at [cfn/stack.yml](https://github.com/tongueroo/ufo/blob/master/lib/cfn/stack.yml). This implementation might change in the future.
34
34
 
35
- {% include prev_next.md %}
35
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Database Migrations
3
- nav_order: 41
3
+ nav_order: 42
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:
@@ -22,4 +22,4 @@ The `ufo task` command is generalized so you can run any one-off task. It is not
22
22
  2. Registers the ECS Task definition
23
23
  3. Runs a one-off ECS Task
24
24
 
25
- {% include prev_next.md %}
25
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Run in Pieces
3
- nav_order: 39
3
+ nav_order: 40
4
4
  ---
5
5
 
6
6
  The `ufo ship` command goes through a few stages:
@@ -27,4 +27,4 @@ Update the service with the task definitions in `.ufo/output` untouched.
27
27
 
28
28
  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`.
29
29
 
30
- {% include prev_next.md %}
30
+ {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Run Single Task
3
- nav_order: 40
3
+ nav_order: 41
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.
@@ -22,4 +22,4 @@ You can describe that task for more details:
22
22
 
23
23
  You can check out the [ufo task](http://ufoships.com/reference/ufo-task/) reference for more details.
24
24
 
25
- {% include prev_next.md %}
25
+ {% include prev_next.md %}