ufo 3.5.7 → 4.0.0

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.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/Gemfile.lock +16 -10
  4. data/README.md +12 -13
  5. data/docs/_config.yml +1 -1
  6. data/docs/_docs/auto-completion.md +4 -4
  7. data/docs/_docs/automated-cleanup.md +1 -1
  8. data/docs/_docs/conventions.md +7 -7
  9. data/docs/_docs/customize-cloudformation.md +36 -0
  10. data/docs/_docs/faq.md +9 -7
  11. data/docs/_docs/fargate.md +102 -0
  12. data/docs/_docs/helpers.md +3 -3
  13. data/docs/_docs/load-balancer.md +72 -0
  14. data/docs/_docs/migrations.md +2 -2
  15. data/docs/_docs/next-steps.md +2 -2
  16. data/docs/_docs/params.md +12 -41
  17. data/docs/_docs/route53-support.md +28 -0
  18. data/docs/_docs/run-in-pieces.md +2 -2
  19. data/docs/_docs/security-groups.md +54 -0
  20. data/docs/_docs/settings-cfn.md +11 -0
  21. data/docs/_docs/settings-network.md +34 -0
  22. data/docs/_docs/settings.md +18 -15
  23. data/docs/_docs/single-task.md +3 -3
  24. data/docs/_docs/ssl-support.md +42 -0
  25. data/docs/_docs/structure.md +5 -1
  26. data/docs/_docs/stuck-cloudformation.md +30 -0
  27. data/docs/_docs/tutorial-ufo-docker-build.md +19 -31
  28. data/docs/_docs/tutorial-ufo-init.md +16 -12
  29. data/docs/_docs/tutorial-ufo-ship.md +50 -54
  30. data/docs/_docs/tutorial-ufo-ships.md +9 -7
  31. data/docs/_docs/tutorial-ufo-tasks-build.md +26 -17
  32. data/docs/_docs/ufo-current.md +50 -0
  33. data/docs/_docs/ufo-env-extra.md +21 -0
  34. data/docs/_docs/ufo-env.md +6 -13
  35. data/docs/_docs/ufo-tasks-register.md +3 -3
  36. data/docs/_docs/upgrade4.md +49 -0
  37. data/docs/_docs/variables.md +5 -5
  38. data/docs/_docs/why-cloudformation.md +22 -0
  39. data/docs/_includes/about.html +1 -1
  40. data/docs/_includes/cfn-customize.md +39 -0
  41. data/docs/_includes/commands.html +6 -6
  42. data/docs/_includes/css/ufo.css +1 -0
  43. data/docs/_includes/example.html +13 -13
  44. data/docs/_includes/reference.md +1 -1
  45. data/docs/_includes/subnav.html +22 -5
  46. data/docs/_includes/ufo-ship-options.md +7 -6
  47. data/docs/_reference/ufo-apps.md +36 -0
  48. data/docs/_reference/ufo-cancel.md +24 -0
  49. data/docs/_reference/ufo-completion.md +1 -1
  50. data/docs/_reference/ufo-completion_script.md +1 -1
  51. data/docs/_reference/ufo-current.md +93 -0
  52. data/docs/_reference/ufo-deploy.md +18 -17
  53. data/docs/_reference/ufo-destroy.md +6 -4
  54. data/docs/_reference/ufo-docker-base.md +7 -7
  55. data/docs/_reference/ufo-docker-build.md +9 -9
  56. data/docs/_reference/ufo-docker-clean.md +8 -8
  57. data/docs/_reference/ufo-docker-name.md +4 -4
  58. data/docs/_reference/ufo-docker.md +4 -2
  59. data/docs/_reference/ufo-init.md +31 -20
  60. data/docs/_reference/ufo-network-help.md +15 -0
  61. data/docs/_reference/ufo-network-init.md +38 -0
  62. data/docs/_reference/ufo-network.md +26 -0
  63. data/docs/_reference/ufo-ps.md +53 -0
  64. data/docs/_reference/ufo-releases.md +40 -0
  65. data/docs/_reference/ufo-resources.md +44 -0
  66. data/docs/_reference/ufo-rollback.md +59 -0
  67. data/docs/_reference/ufo-scale.md +23 -3
  68. data/docs/_reference/ufo-ship.md +54 -27
  69. data/docs/_reference/ufo-ships.md +17 -26
  70. data/docs/_reference/ufo-stop.md +31 -0
  71. data/docs/_reference/ufo-task.md +15 -16
  72. data/docs/_reference/ufo-tasks-build.md +10 -10
  73. data/docs/_reference/ufo-tasks-register.md +3 -3
  74. data/docs/_reference/ufo-tasks.md +1 -1
  75. data/docs/_reference/ufo-upgrade-help.md +15 -0
  76. data/docs/_reference/ufo-upgrade-v2to3.md +15 -0
  77. data/docs/_reference/ufo-upgrade-v3_3to3_4.md +15 -0
  78. data/docs/_reference/ufo-upgrade-v3to4.md +27 -0
  79. data/docs/_reference/ufo-upgrade.md +28 -0
  80. data/docs/_reference/ufo-version.md +1 -1
  81. data/docs/articles.md +2 -2
  82. data/docs/docs.md +1 -1
  83. data/docs/img/docs/cloudformation-resources.png +0 -0
  84. data/docs/img/tutorials/ecs-console-task-definitions.png +0 -0
  85. data/docs/img/tutorials/ecs-console-ufo-ship.png +0 -0
  86. data/docs/img/tutorials/ecs-console-ufo-ships.png +0 -0
  87. data/docs/quick-start.md +21 -9
  88. data/docs/reference.md +10 -2
  89. data/exe/ufo +1 -1
  90. data/lib/cfn/stack.yml +259 -0
  91. data/lib/template/.ufo/params.yml.tt +21 -60
  92. data/lib/template/.ufo/settings.yml.tt +6 -1
  93. data/lib/template/.ufo/settings/cfn/default.yml.tt +55 -0
  94. data/lib/template/.ufo/settings/network/default.yml.tt +18 -0
  95. data/lib/template/.ufo/task_definitions.rb.tt +7 -6
  96. data/lib/template/.ufo/templates/fargate.json.erb +1 -1
  97. data/lib/template/.ufo/templates/main.json.erb +1 -0
  98. data/lib/template/.ufo/variables/base.rb.tt +5 -2
  99. data/lib/template/Dockerfile +10 -15
  100. data/lib/template/bin/deploy.tt +2 -2
  101. data/lib/ufo.rb +29 -20
  102. data/lib/ufo/apps.rb +49 -0
  103. data/lib/ufo/apps/cfn_map.rb +70 -0
  104. data/lib/ufo/apps/service.rb +56 -0
  105. data/lib/ufo/aws_service.rb +15 -6
  106. data/lib/ufo/base.rb +32 -0
  107. data/lib/ufo/cancel.rb +23 -0
  108. data/lib/ufo/cli.rb +91 -27
  109. data/lib/ufo/core.rb +35 -3
  110. data/lib/ufo/current.rb +104 -0
  111. data/lib/ufo/destroy.rb +10 -41
  112. data/lib/ufo/docker/builder.rb +5 -4
  113. data/lib/ufo/docker/cleaner.rb +1 -1
  114. data/lib/ufo/docker/pusher.rb +2 -2
  115. data/lib/ufo/ecr/cleaner.rb +1 -1
  116. data/lib/ufo/help/apps.md +12 -0
  117. data/lib/ufo/help/balancer.md +3 -0
  118. data/lib/ufo/help/current.md +65 -0
  119. data/lib/ufo/help/deploy.md +4 -4
  120. data/lib/ufo/help/destroy.md +3 -3
  121. data/lib/ufo/help/docker.md +3 -1
  122. data/lib/ufo/help/docker/base.md +7 -7
  123. data/lib/ufo/help/docker/build.md +9 -9
  124. data/lib/ufo/help/docker/clean.md +8 -8
  125. data/lib/ufo/help/docker/name.md +4 -4
  126. data/lib/ufo/help/help.md +5 -0
  127. data/lib/ufo/help/init.md +24 -16
  128. data/lib/ufo/help/network/init.md +13 -0
  129. data/lib/ufo/help/ps.md +27 -0
  130. data/lib/ufo/help/releases.md +16 -0
  131. data/lib/ufo/help/resources.md +20 -0
  132. data/lib/ufo/help/rollback.md +35 -0
  133. data/lib/ufo/help/scale.md +22 -2
  134. data/lib/ufo/help/ship.md +40 -14
  135. data/lib/ufo/help/ships.md +4 -13
  136. data/lib/ufo/help/stop.md +7 -0
  137. data/lib/ufo/help/task.md +9 -9
  138. data/lib/ufo/help/tasks/build.md +10 -10
  139. data/lib/ufo/help/tasks/register.md +3 -3
  140. data/lib/ufo/help/upgrade/v3to4.md +3 -0
  141. data/lib/ufo/info.rb +62 -0
  142. data/lib/ufo/init.rb +36 -23
  143. data/lib/ufo/log_group.rb +2 -1
  144. data/lib/ufo/network.rb +24 -0
  145. data/lib/ufo/network/fetch.rb +41 -0
  146. data/lib/ufo/network/helper.rb +23 -0
  147. data/lib/ufo/network/init.rb +26 -0
  148. data/lib/ufo/param.rb +5 -5
  149. data/lib/ufo/ps.rb +102 -0
  150. data/lib/ufo/ps/task.rb +78 -0
  151. data/lib/ufo/releases.rb +14 -0
  152. data/lib/ufo/rollback.rb +53 -0
  153. data/lib/ufo/scale.rb +6 -12
  154. data/lib/ufo/sequence.rb +7 -0
  155. data/lib/ufo/setting.rb +7 -6
  156. data/lib/ufo/setting/profile.rb +24 -0
  157. data/lib/ufo/ship.rb +35 -326
  158. data/lib/ufo/stack.rb +203 -0
  159. data/lib/ufo/stack/context.rb +242 -0
  160. data/lib/ufo/stack/helper.rb +28 -0
  161. data/lib/ufo/stack/status.rb +195 -0
  162. data/lib/ufo/stop.rb +47 -0
  163. data/lib/ufo/task.rb +96 -15
  164. data/lib/ufo/tasks/register.rb +1 -1
  165. data/lib/ufo/template_scope.rb +81 -7
  166. data/lib/ufo/upgrade.rb +32 -0
  167. data/lib/ufo/{upgrade3.rb → upgrade/upgrade3.rb} +1 -1
  168. data/lib/ufo/{upgrade33_to_34.rb → upgrade/upgrade33to34.rb} +2 -2
  169. data/lib/ufo/upgrade/upgrade4.rb +161 -0
  170. data/lib/ufo/util.rb +19 -6
  171. data/lib/ufo/version.rb +1 -1
  172. data/spec/fixtures/apps/describe_services.json +96 -0
  173. data/spec/fixtures/cfn/stack-events-complete.json +1080 -0
  174. data/spec/fixtures/cfn/stack-events-in-progress.json +1080 -0
  175. data/spec/fixtures/cfn/stack-events-update-rollback-complete.json +1086 -0
  176. data/spec/fixtures/deployments.json +50 -0
  177. data/spec/fixtures/ps/describe_tasks.json +58 -0
  178. data/spec/fixtures/settings.yml +2 -0
  179. data/spec/lib/apps_spec.rb +20 -0
  180. data/spec/lib/cli_spec.rb +4 -4
  181. data/spec/lib/ps_spec.rb +14 -0
  182. data/spec/lib/setting_spec.rb +2 -1
  183. data/spec/lib/ship_spec.rb +6 -30
  184. data/spec/lib/stack/status_spec.rb +76 -0
  185. data/spec/lib/stop_spec.rb +13 -0
  186. data/spec/lib/task_spec.rb +5 -2
  187. data/spec/spec_helper.rb +1 -1
  188. data/ufo.gemspec +2 -0
  189. metadata +120 -6
  190. data/docs/_reference/ufo-upgrade3.md +0 -23
  191. data/docs/_reference/ufo-upgrade3_3_to_3_4.md +0 -23
@@ -1,66 +1,27 @@
1
- <%%
2
- # replace with actual values if using fargate
3
- @subnets = ["subnet-111","subnet-222"]
4
- @security_groups = ["sg-111"]
5
- %>
6
1
  # These params are passsed to the corresponding aws-sdk ecs client methods.
7
2
  # AWS Docs example: https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ECS/Client.html#run_task-instance_method
8
3
  #
9
- # Comments left in as examples.
10
- # Uncomment launch_type and network_configuration sections to enable fargate.
4
+ # The network helper provides access to the .ufo/settings/network/[PROFILE].yml
11
5
  #
12
6
  # More docs: http://ufoships.com/docs/params/
13
7
 
14
- create_service:
15
- deployment_configuration:
16
- maximum_percent: 200
17
- minimum_healthy_percent: 100
18
- desired_count: 1
19
- <% if @options[:launch_type] == "fargate" -%>
20
- launch_type: "FARGATE"
21
- network_configuration:
22
- awsvpc_configuration:
23
- subnets: <%%= @subnets.inspect %> # required
24
- security_groups: <%%= @security_groups.inspect %>
25
- assign_public_ip: "ENABLED" # accepts ENABLED, DISABLED
26
- <% else -%>
27
- # launch_type: "FARGATE"
28
- # network_configuration:
29
- # awsvpc_configuration:
30
- # subnets: <%%= @subnets.inspect %> # required
31
- # security_groups: <%%= @security_groups.inspect %>
32
- # assign_public_ip: "ENABLED" # accepts ENABLED, DISABLED
33
- <% end -%>
34
-
35
- # update service is provide as an example below. Though it is probably better
36
- # to not add any options to update_service if you are using the ECS console
37
- # to update these settings often.
38
- update_service:
39
- # force_new_deployment: true
40
- # deployment_configuration:
41
- # maximum_percent: 200
42
- # minimum_healthy_percent: 100
43
- # desired_count: 1
44
- # launch_type: "FARGATE"
45
- # network_configuration:
46
- # awsvpc_configuration:
47
- # subnets: <%%= @subnets.inspect %> # required
48
- # security_groups: <%%= @security_groups.inspect %>
49
- # assign_public_ip: "ENABLED" # accepts ENABLED, DISABLED
50
-
51
- run_task:
52
- <% if @options[:launch_type] == "fargate" -%>
53
- launch_type: "FARGATE"
54
- network_configuration:
55
- awsvpc_configuration:
56
- subnets: <%%= @subnets.inspect %> # required
57
- security_groups: <%%= @security_groups.inspect %>
58
- assign_public_ip: "ENABLED" # accepts ENABLED, DISABLED
59
- <% else -%>
60
- # launch_type: "FARGATE"
61
- # network_configuration:
62
- # awsvpc_configuration:
63
- # subnets: <%%= @subnets.inspect %> # required
64
- # security_groups: <%%= @security_groups.inspect %>
65
- # assign_public_ip: "ENABLED" # accepts ENABLED, DISABLED
66
- <% end -%>
8
+ # ufo task calls run_tasks.
9
+ #
10
+ # ufo task will assign these values appropriately based on the task
11
+ # definition being ran. So generally you should you can leave these settings
12
+ # alone.
13
+ #
14
+ # If it's a Fargate task definition, ufo task automatically adds the
15
+ # network_configuration and launch_type: FARGATE
16
+ # If it's a EC2 task definition with awsvpc network mode, ufo task
17
+ # automatically adds the network_configuration and security groups using
18
+ # the security groups from .ufo/settings/network/default.yml.
19
+ #
20
+ # run_task:
21
+ # # network_configuration is required for FARGATE
22
+ # network_configuration:
23
+ # awsvpc_configuration:
24
+ # subnets: <%%= network[:ecs_subnets].inspect %> # required
25
+ # security_groups: <%%= network[:ecs_security_groups].inspect %>
26
+ # # for fargate use: assign_public_ip: ENABLED
27
+ # # assign_public_ip: ENABLED # accepts ENABLED, DISABLED
@@ -6,7 +6,12 @@ base:
6
6
  image: <%= @image %>
7
7
  # clean_keep: 30
8
8
  # ecr_keep: 30
9
- # defaults when an new ECS service is created by ufo ship
9
+ network_profile: default # .ufo/settings/network/default.yml file
10
+ cfn_profile: default # .ufo/settings/cfn/default.yml file
11
+ # If you want to have prettier name set for the ECS service name
12
+ # There are some cavaets with this. Updating properties on resources that require
13
+ # replacment might not work. For example, adding and removing a load balancer.
14
+ # In these cases, you must delete the entire ecs service and recreate it.
10
15
 
11
16
  development:
12
17
  # cluster: development
@@ -0,0 +1,55 @@
1
+ ---
2
+ # Options allow you to customize any resources that ufo creates with
3
+ # CloudFormation. These options are inserting into the generated template.
4
+ # More info: https://ufoships.com/docs/customize-cloudformation
5
+
6
+ elb:
7
+ scheme: internet-facing
8
+
9
+ # https://docs.aws.amazon.com/fr_fr/elasticloadbalancing/latest/APIReference/API_CreateTargetGroup.html
10
+ #
11
+ # When using SSL with network elb, the target group protocol is usually http still
12
+ # unless you also handle SSL termination at the app level.
13
+ target_group:
14
+ port: 80 # only used with ECS if awsvpc mode
15
+ # protocol: TCP # valid values - application elb: HTTP HTTPS, network elb: TCP
16
+ # ufo sets defaults in cloudformation template
17
+ # application elb: HTTP
18
+ # network elb: TCP
19
+ # so we can keep this commented out, unless we need HTTPS at the app level
20
+ target_group_attributes:
21
+ - key: deregistration_delay.timeout_seconds
22
+ value: 1
23
+ # network elb support health_check_interval_seconds of 10 or 30
24
+ # health_check_interval_seconds: 30
25
+
26
+ # health check settings are supported by application load balancer only:
27
+ # health_check_protocol: HTTP # HTTP or HTTPS
28
+ # health_check_path: /
29
+ # health_check_port: traffic-port
30
+ # unhealthy_threshold_count: 10
31
+
32
+ # https://docs.aws.amazon.com/fr_fr/elasticloadbalancing/latest/APIReference/API_CreateListener.html
33
+ #
34
+ # If HTTPS and SSL is required this is where it would normally be set. Application ELBs
35
+ # support SSL termination. Network load balancers do not.
36
+ listener:
37
+ port: 80 # required by ufo, used in cloudformation template
38
+ # For Application Load Balancers, the supported protocols are HTTP and HTTPS. For Network Load Balancers, the supported protocol is TCP.
39
+ # protocol: TCP # valid values - application elb: HTTP HTTPS, network elb: TCP
40
+ # ufo sets defaults in cloudformation template
41
+ # application elb: HTTP
42
+ # network elb: TCP
43
+ # so we can keep this commented out, unless we need HTTPS at elb level
44
+ # certificates is required if using HTTPS protocol with application
45
+ # certificates:
46
+ # - certificate: arn:aws:acm:us-east-1:111111111111:certificate/11111111-2222-3333-4444-555555555555
47
+
48
+ # Configure dns to automatically be associated with the ELB dns name.
49
+ # Note, the route53 record set for the domain name must already exist.
50
+ # The {stack_name} variable gets replaced with the name of the CloudFormation stack name.
51
+ # Example: {stack_name} => demo-web
52
+ # dns:
53
+ # name: "{stack_name}.yourdomain."
54
+ # hosted_zone_name: yourdomain. # dont forget the trailing period
55
+ # TTL: '60' # ttl has special upcase casing
@@ -0,0 +1,18 @@
1
+ ---
2
+ vpc: <%= @options[:vpc_id] %>
3
+ ecs_subnets: # required: at least 2 subnets
4
+ <% @options[:ecs_subnets].each do |subnet| -%>
5
+ - <%= subnet %>
6
+ <% end -%>
7
+ elb_subnets: # defaults to same subnets as ecs_subnets when not set
8
+ <% @options[:elb_subnets].each do |subnet| -%>
9
+ - <%= subnet %>
10
+ <% end -%>
11
+
12
+ # Optional additional existing security group ids to add on top of the ones created
13
+ # by ufo.
14
+ # elb_security_groups:
15
+ # - sg-aaa
16
+ # ecs_security_groups:
17
+ # - sg-bbb
18
+ # - sg-ccc
@@ -11,8 +11,9 @@
11
11
  #
12
12
  # More info: http://ufoships.com/docs/helpers/
13
13
  #
14
+ <% source_name = @options[:launch_type] == "fargate" ? "fargate" : "main" -%>
14
15
  task_definition "<%= @app %>-web" do
15
- source "main" # will use ufo/templates/main.json.erb
16
+ source "<%= source_name %>" # will use ufo/templates/<%= source_name %>.json.erb
16
17
  variables(
17
18
  family: task_definition_name,
18
19
  name: "web",
@@ -26,7 +27,7 @@ task_definition "<%= @app %>-web" do
26
27
  # prefix-name/container-name/ecs-task-id
27
28
  # Here's an exmaple when you specify the prefix of "demo"
28
29
  # demo/web/209e93b4-5523-4496-9a27-662fd151eb78
29
- awslogs_group: "ecs/<%= @app %>-web",
30
+ awslogs_group: ["ecs/<%= @app %>-web", Ufo.env_extra].compact.join('-'),
30
31
  awslogs_stream_prefix: "<%= @app %>",
31
32
  awslogs_region: helper.current_region,
32
33
  # command: ["bin/web"] # IMPORTANT: change or create a bin/web file
@@ -34,12 +35,12 @@ task_definition "<%= @app %>-web" do
34
35
  end
35
36
 
36
37
  task_definition "<%= @app %>-worker" do
37
- source "main" # will use ufo/templates/main.json.erb
38
+ source "<%= source_name %>" # will use ufo/templates/<%= source_name %>.json.erb
38
39
  variables(
39
40
  family: task_definition_name,
40
41
  name: "worker",
41
42
  # Comment out awslogs_* if you do not want logs to be sent to CloudWatch.
42
- awslogs_group: "ecs/<%= @app %>-worker",
43
+ awslogs_group: ["ecs/<%= @app %>-worker", Ufo.env_extra].compact.join('-'),
43
44
  awslogs_stream_prefix: "<%= @app %>",
44
45
  awslogs_region: helper.current_region,
45
46
  # command: ["bin/worker"] # IMPORTANT: change or create a bin/worker file
@@ -47,12 +48,12 @@ task_definition "<%= @app %>-worker" do
47
48
  end
48
49
 
49
50
  task_definition "<%= @app %>-clock" do
50
- source "main" # will use ufo/templates/main.json.erb
51
+ source "<%= source_name %>" # will use ufo/templates/<%= source_name %>.json.erb
51
52
  variables(
52
53
  family: task_definition_name,
53
54
  name: "clock",
54
55
  # Comment out awslogs_* if you do not want logs to be sent to CloudWatch.
55
- awslogs_group: "ecs/<%= @app %>-clock",
56
+ awslogs_group: ["ecs/<%= @app %>-clock", Ufo.env_extra].compact.join('-'),
56
57
  awslogs_stream_prefix: "<%= @app %>",
57
58
  awslogs_region: helper.current_region,
58
59
  # command: ["bin/clock"] # IMPORTANT: change or create a bin/clock file
@@ -2,7 +2,7 @@
2
2
  "family": "<%= @family %>",
3
3
  "requiresCompatibilities": ["FARGATE"],
4
4
  "networkMode": "awsvpc",
5
- "executionRoleArn": "<%= @execution_role_arn %>",
5
+ "executionRoleArn": "<%= @execution_role_arn || raise("@execution_role_arn needs to be set") %>",
6
6
  "cpu": "<%= @cpu %>",
7
7
  "memory": "<%= @memory %>",
8
8
  "containerDefinitions": [
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "family": "<%= @family %>",
3
+ <%# "networkMode": "awsvpc", %>
3
4
  "containerDefinitions": [
4
5
  {
5
6
  "name": "<%= @name %>",
@@ -1,6 +1,6 @@
1
1
  # Example ufo/variables/base.rb
2
2
  # More info on how variables work: http://ufoships.com/docs/variables/
3
- @image = helper.full_image_name # includes the git sha tongueroo/hi:ufo-[sha].
3
+ @image = helper.full_image_name # includes the git sha tongueroo/demo-ufo:ufo-[sha].
4
4
  @environment = helper.env_file(".env")
5
5
  <% if @options[:launch_type] == "fargate" -%>
6
6
  # Ensure that the cpu and memory values are a supported combination by Fargate.
@@ -8,8 +8,11 @@
8
8
  <% end -%>
9
9
  @cpu = 256
10
10
  @memory = 512
11
- @memory_reservation = 256
11
+ @memory_reservation = 512
12
12
 
13
13
  <% if @execution_role_arn_input -%>
14
14
  @execution_role_arn = "<%= @execution_role_arn_input %>"
15
+ <% else -%>
16
+ # required for fargate
17
+ # @execution_role_arn = "..."
15
18
  <% end -%>
@@ -1,20 +1,15 @@
1
- FROM ruby:2.5.0
2
- MAINTAINER Tung Nguyen <tongueroo@gmail.com>
1
+ FROM ruby:2.5.1
3
2
 
4
- # This is just a sample Dockerfile. This is meant to be overriden.
3
+ WORKDIR /app
4
+ ADD Gemfile /app/Gemfile
5
+ ADD Gemfile.lock /app/Gemfile.lock
6
+ RUN bundle install --system
5
7
 
6
- # Install bundle of gems first in a layer
7
- # so if the Gemfile doesnt chagne it wont have to install gems again
8
- WORKDIR /tmp
9
- COPY Gemfile* /tmp/
10
- RUN bundle install && rm -rf /root/.bundle/cache
8
+ ADD . /app
9
+ RUN bundle install --system
11
10
 
12
- # Add the Rails app
13
- ENV HOME /root
14
- WORKDIR /app
15
- COPY . /app
16
- RUN bundle install
17
- RUN mkdir -p tmp/cache tmp/pids
11
+ EXPOSE 4567
18
12
 
19
- EXPOSE 5001
13
+ # If you do not have a bin/web wrapper file, create one or update this command
14
+ RUN chmod a+x bin/web
20
15
  CMD ["bin/web"]
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash -xe
2
2
 
3
- # Generated started bin/deploy script. Meant to be example only and should probably
4
- # be overridden.
3
+ # Generated starter bin/deploy script example.
4
+ # Meant to be overridden.
5
5
 
6
6
  # Only build one docker image and deploys it to multiple ECS services
7
7
  ufo ships <%= @app %>-{web,clock,worker}
data/lib/ufo.rb CHANGED
@@ -4,35 +4,44 @@ require 'deep_merge'
4
4
  require 'colorize'
5
5
  require 'fileutils'
6
6
  require 'render_me_pretty'
7
+ require 'memoist'
7
8
 
8
9
  module Ufo
9
- autoload :Core, 'ufo/core'
10
+ autoload :Apps, 'ufo/apps'
10
11
  autoload :AwsService, 'ufo/aws_service'
11
- autoload :Command, 'ufo/command'
12
- autoload :Setting, 'ufo/setting'
13
- autoload :Util, 'ufo/util'
14
- autoload :Init, 'ufo/init'
15
- autoload :Sequence, 'ufo/sequence'
12
+ autoload :Base, 'ufo/base'
13
+ autoload :Cancel, 'ufo/cancel'
16
14
  autoload :CLI, 'ufo/cli'
17
- autoload :Help, 'ufo/help'
18
- autoload :Ship, 'ufo/ship'
19
- autoload :Task, 'ufo/task'
15
+ autoload :Command, 'ufo/command'
16
+ autoload :Completer, "ufo/completer"
17
+ autoload :Completion, "ufo/completion"
18
+ autoload :Core, 'ufo/core'
19
+ autoload :Current, 'ufo/current'
20
20
  autoload :Destroy, 'ufo/destroy'
21
+ autoload :Docker, 'ufo/docker'
21
22
  autoload :DSL, 'ufo/dsl'
22
- autoload :Scale, 'ufo/scale'
23
- autoload :LogGroup, 'ufo/log_group'
23
+ autoload :Ecr, 'ufo/ecr'
24
24
  autoload :ECS, 'ufo/ecs'
25
+ autoload :Help, 'ufo/help'
26
+ autoload :Info, 'ufo/info'
27
+ autoload :Init, 'ufo/init'
28
+ autoload :LogGroup, 'ufo/log_group'
29
+ autoload :Network, 'ufo/network'
25
30
  autoload :Param, 'ufo/param'
26
- autoload :TemplateScope, 'ufo/template_scope'
27
-
28
- autoload :Docker, 'ufo/docker'
29
- autoload :Ecr, 'ufo/ecr'
31
+ autoload :Ps, 'ufo/ps'
32
+ autoload :Releases, 'ufo/releases'
33
+ autoload :Rollback, 'ufo/rollback'
34
+ autoload :Scale, 'ufo/scale'
35
+ autoload :Sequence, 'ufo/sequence'
36
+ autoload :Setting, 'ufo/setting'
37
+ autoload :Ship, 'ufo/ship'
38
+ autoload :Stack, 'ufo/stack'
39
+ autoload :Stop, 'ufo/stop'
40
+ autoload :Task, 'ufo/task'
30
41
  autoload :Tasks, 'ufo/tasks'
31
- autoload :Completion, "ufo/completion"
32
- autoload :Completer, "ufo/completer"
33
- autoload :Upgrade3, "ufo/upgrade3"
34
- autoload :Upgrade33_to_34, "ufo/upgrade33_to_34"
42
+ autoload :TemplateScope, 'ufo/template_scope'
43
+ autoload :Upgrade, "ufo/upgrade"
44
+ autoload :Util, 'ufo/util'
35
45
 
36
46
  extend Core
37
47
  end
38
-
@@ -0,0 +1,49 @@
1
+ require 'text-table'
2
+
3
+ module Ufo
4
+ class Apps
5
+ autoload :CfnMap, "ufo/apps/cfn_map"
6
+ autoload :Service, "ufo/apps/service"
7
+
8
+ extend Memoist
9
+ include Stack::Helper
10
+
11
+ def initialize(options)
12
+ @options = options
13
+ @cluster = @options[:cluster] || default_cluster
14
+ end
15
+
16
+ def list
17
+ begin
18
+ resp = ecs.list_services(cluster: @cluster)
19
+ rescue Aws::ECS::Errors::ClusterNotFoundException => e
20
+ puts "ECS cluster #{@cluster.colorize(:green)} not found."
21
+ exit 1
22
+ end
23
+ arns = resp.service_arns.sort
24
+
25
+ puts "Listing ECS services in the #{@cluster.colorize(:green)} cluster."
26
+ if arns.empty?
27
+ puts "No ECS services found in the #{@cluster.colorize(:green)} cluster."
28
+ return
29
+ end
30
+
31
+ resp = ecs.describe_services(services: arns, cluster: @cluster)
32
+ display_info(resp)
33
+ end
34
+
35
+ def display_info(resp)
36
+ table = Text::Table.new
37
+ table.head = ["Service Name", "Task Definition", "Running", "Launch type", "Ufo?"]
38
+ resp["services"].each do |s|
39
+ table.rows << service_info(s)
40
+ end
41
+ puts table unless ENV['TEST']
42
+ end
43
+
44
+ # for specs
45
+ def service_info(s)
46
+ Service.new(s, @options).to_a
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,70 @@
1
+ class Ufo::Apps
2
+ class CfnMap
3
+ extend Memoist
4
+ include Ufo::Stack::Helper
5
+
6
+ def initialize(options = {})
7
+ @options = options
8
+ @cluster = @options[:cluster] || default_cluster
9
+ @map = {}
10
+ end
11
+
12
+ # Example:
13
+ # {"development-demo-web-Ecs-1L3WUTJFFM5JV"=>"demo-web"}
14
+ def map
15
+ return @map if @populated
16
+
17
+ populate_map!
18
+ @populated = true
19
+ @map
20
+ end
21
+
22
+ def summaries
23
+ filter = %w[
24
+ UPDATE_COMPLETE
25
+ CREATE_COMPLETE
26
+ UPDATE_ROLLBACK_COMPLETE
27
+ UPDATE_IN_PROGRESS
28
+ UPDATE_COMPLETE_CLEANUP_IN_PROGRESS
29
+ UPDATE_ROLLBACK_IN_PROGRESS
30
+ UPDATE_ROLLBACK_FAILED
31
+ UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS
32
+ REVIEW_IN_PROGRESS
33
+ ]
34
+
35
+ summaries = []
36
+ next_token = true
37
+ while next_token
38
+ resp = cloudformation.list_stacks(stack_status_filter: filter)
39
+ summaries += resp.stack_summaries
40
+ next_token = resp.next_token
41
+ end
42
+
43
+ # look for stacks that beling that ufo create
44
+ summaries.select do |s|
45
+ s.template_description =~ /Ufo ECS stack/
46
+ end
47
+ end
48
+ memoize :summaries
49
+
50
+ def populate_map!
51
+ threads = []
52
+ summaries.each do |summary|
53
+ threads << Thread.new do
54
+ resp = cloudformation.describe_stack_resources(stack_name: summary.stack_name)
55
+ ecs_resource = resp.stack_resources.find do |resource|
56
+ resource.logical_resource_id == "Ecs"
57
+ end
58
+ # Example: "PhysicalResourceId": "arn:aws:ecs:us-east-1:111111111111:service/dev-demo-web-Ecs-1HRL8Y9F4D1CR"
59
+ ecs_service_name = ecs_resource.physical_resource_id.split('/').last
60
+ @map[ecs_service_name] = stack_name_to_service_name(summary.stack_name)
61
+ end
62
+ end
63
+ threads.map(&:join)
64
+ end
65
+
66
+ def stack_name_to_service_name(stack_name)
67
+ stack_name.sub("#{@cluster}-",'')
68
+ end
69
+ end
70
+ end