ufo 6.1.5 → 6.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.cody/acceptance/bin/build.sh +1 -1
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +84 -0
  4. data/.github/ISSUE_TEMPLATE/documentation.md +12 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +64 -0
  6. data/.github/ISSUE_TEMPLATE/question.md +14 -0
  7. data/.github/ISSUE_TEMPLATE.md +7 -0
  8. data/.github/PULL_REQUEST_TEMPLATE.md +50 -0
  9. data/CHANGELOG.md +11 -0
  10. data/lib/ufo/aws_services/concerns.rb +55 -0
  11. data/lib/ufo/aws_services.rb +9 -40
  12. data/lib/ufo/cfn/stack/builder.rb +2 -1
  13. data/lib/ufo/cfn/stack/params.rb +2 -1
  14. data/lib/ufo/cfn/stack/status.rb +1 -1
  15. data/lib/ufo/cfn/stack.rb +4 -4
  16. data/lib/ufo/cli/destroy.rb +1 -1
  17. data/lib/ufo/cli/ps/errors.rb +40 -0
  18. data/lib/ufo/command.rb +17 -7
  19. data/lib/ufo/config.rb +47 -3
  20. data/lib/ufo/docker/builder.rb +1 -1
  21. data/lib/ufo/docker/compiler.rb +3 -3
  22. data/lib/ufo/docker/state/base.rb +14 -0
  23. data/lib/ufo/docker/state/bucket.rb +2 -0
  24. data/lib/ufo/docker/state/file.rb +52 -0
  25. data/lib/ufo/docker/state/s3.rb +80 -0
  26. data/lib/ufo/docker/state.rb +16 -50
  27. data/lib/ufo/info.rb +1 -1
  28. data/lib/ufo/layering/layer.rb +27 -37
  29. data/lib/ufo/s3/aws_setup.rb +17 -0
  30. data/lib/ufo/s3/bucket.rb +174 -0
  31. data/lib/ufo/s3/rollback.rb +52 -0
  32. data/lib/ufo/task_definition/erb.rb +2 -2
  33. data/lib/ufo/task_definition/helpers/{core.rb → docker.rb} +9 -24
  34. data/lib/ufo/task_definition/helpers/{aws_helper.rb → vars/aws_helper.rb} +2 -1
  35. data/lib/ufo/task_definition/helpers/vars/builder.rb +124 -0
  36. data/lib/ufo/task_definition/helpers/vars.rb +11 -114
  37. data/lib/ufo/upgrade/upgrade4.rb +0 -9
  38. data/lib/ufo/version.rb +1 -1
  39. data/ufo.gemspec +1 -0
  40. metadata +33 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5f634a56ad0e21b377ac92fb03f9b745a0f9e889e3a0b2b11f0f4b03c2a40b0
4
- data.tar.gz: 3cbc84d12fd991d62f85f53792319b170fc033e77d7191fc666aa4c124b0d1f9
3
+ metadata.gz: e630cb6fc68958a6b7f7264e6b0ff03a2d41ae13d9a1648bd13fa601d9f9aae0
4
+ data.tar.gz: 2693b4ca4e3e5ffa31ff881f706de093792d93a4ff7263820308565d44685c38
5
5
  SHA512:
6
- metadata.gz: fb24c7425643f9b9013f54309205c908eae46fcfbd66795d31d5067fba472280b8744b85a0d7ea9de9f684cd00ae4df6e7114c2ff051450d9d00e1ca36999945
7
- data.tar.gz: 6c6cf2c3d47ff6edf45a327503b4590e9edbd38ce7cc2fc9d3b320bb4fb8d50240754fa6d6aa90e7e7e203af141de65b6140fdb98d0c4eeda031204545f558dd
6
+ metadata.gz: 116244ca9466e2458845904b34d99bc1fd2e7d1d8379c32066d2f90d70cfe7eb84628552a8250f7d4cca13dcdcf1cdad0ba812e602ba1df25c4f0b383131c057
7
+ data.tar.gz: 7e7aa81c1595f231465f1694a80dc7e4f0a8f7f7c77399e28b12b71c109a2c5ea0b9674fd0e8a9b485792253e16c4fd4a27734a121affd01bb69e163fb6e9f51
@@ -22,7 +22,7 @@ REPO=$(aws ecr describe-repositories --repository-name test/demo | jq -r '.repos
22
22
 
23
23
  # DockerHub
24
24
  # toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating
25
- docker login --username $DOCKER_USER --password $DOCKER_PASS
25
+ echo "$DOCKER_PASS" | docker login --username $DOCKER_USER --password-stdin
26
26
  TOKEN=$(curl -s --user "$DOCKER_USER:$DOCKER_PASS" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
27
27
  echo "Current rate limit:"
28
28
  curl -s --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
@@ -0,0 +1,84 @@
1
+ ---
2
+ name: Reproducible Bug Report
3
+ about: Is something not working as expected?
4
+ title: ''
5
+ labels: 'bug'
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!--
11
+ Hi! Thanks for considering to file a bug with UFO. Please take the time to
12
+ answer the basic questions. Please try to be as detailed as possible.
13
+ To be sensitive to everyone's time, if not enough details are provided, the
14
+ issue may be closed without comment. If you repeatedly fail to provide enough
15
+ details, you may be blocked from ever submitting issues to UFO again.
16
+ Please use your best judgment. 👍
17
+
18
+ If you are unsure this is a bug in UFO, please consider asking your question at:
19
+ https://community.boltops.com
20
+
21
+ Thanks!
22
+ -->
23
+
24
+ ## Checklist
25
+
26
+ <!--
27
+ Make sure that you've done all of these. To mark a checkbox done, replace [ ] with [x]. Or after you create the issue you can click the checkbox.
28
+ -->
29
+
30
+ - [ ] Upgrade UFO: Are you using the latest version of UFO? This allows UFO to fix issues fast. There's an Upgrading Guide: https://ufoships.com/docs/upgrading/
31
+ - [ ] Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.boltops.com
32
+ - [ ] Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.
33
+
34
+ ## My Environment
35
+
36
+ <!-- Please fill out the table below with debugging info to help: -->
37
+
38
+ | Software | Version |
39
+ | ---------------- | ------- |
40
+ | Operating System | |
41
+ | UFO | |
42
+ | Ruby | |
43
+
44
+ ---
45
+
46
+ ## Expected Behaviour
47
+
48
+ <!--
49
+ What is it you expected to happen? This should be a description of how the functionality you tried to use is supposed to work. Try to keep this to one-paragraph.
50
+ -->
51
+
52
+ ## Current Behavior
53
+
54
+ <!--
55
+ Describe the details of the bug. Try to keep this to one-paragraph.
56
+ -->
57
+
58
+ ## Step-by-step reproduction instructions
59
+
60
+ <!--
61
+ Be sure to include any steps you took for the problem to exist. This is likely the longest part of the report.
62
+
63
+ Please include any logs you think relevant here. If the logs are long (more than 50 lines) please make a gist of the logs and link to it. https://gist.github.com
64
+
65
+ With long logs, you can also use the <details> tag to keep the report readable. Example:
66
+
67
+ <details>
68
+ <summary>Summary Goes Here</summary>
69
+
70
+ ...this is hidden, collapsable content. start with a blank line to get terminal output to format right...
71
+ </details>
72
+ -->
73
+
74
+ ## Code Sample
75
+
76
+ <!--
77
+ Please provide a code repository, gist, code snippet or sample files to reproduce the issue.
78
+ -->
79
+
80
+ ## Solution Suggestion
81
+
82
+ <!--
83
+ Please provide possible solutions. If you can't think of anything, feel free to omit. Please be kind and add helpful possible solutions. For example, "Fix it!" is not a helpful solution suggestion. We are mere mortals. Please be constructive.
84
+ -->
@@ -0,0 +1,12 @@
1
+ ---
2
+ name: Documentation
3
+ about: Found a typo or something that isn't crystal clear in the docs?
4
+ title: ''
5
+ labels: docs
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ The UFO Docs are in the [ufo-docs repo](https://github.com/boltops-tools/ufo-docs). Please submit a PR there. Thanks!
11
+
12
+ For documentation changes to the ufo code base itself, like code comments. Please submit a PR here. Thanks!
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: New Feature Suggestion
3
+ about: Want to add a feature to UFO?
4
+ title: ''
5
+ labels: feature
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ <!--
11
+ Hi! Thanks for considering to file a feature request with UFO. Please take the time to answer the basic questions. Please try to be as detailed as possible.
12
+
13
+ Thanks!
14
+ -->
15
+
16
+ ## Summary
17
+
18
+ <!--
19
+ A one-paragraph explanation of the feature.
20
+ -->
21
+
22
+ ## Motivation
23
+
24
+ <!--
25
+ Why do you want to see this feature in UFO? What use cases does it support?
26
+
27
+ How the feature would be relevant to 80% or more of UFO users.
28
+ -->
29
+
30
+ ## Guide-level explanation
31
+
32
+ <!--
33
+ Explain the proposal as if it was already included in the project and you were teaching it to another programmer. That generally means:
34
+
35
+ - Introducing new named concepts.
36
+ - Explaining the feature largely in terms of examples.
37
+ - If applicable, provide sample error messages, deprecation warnings, or upgrade guidance.
38
+
39
+ If this is a small feature, you may omit this section.
40
+ -->
41
+
42
+ ## Reference-level explanation
43
+
44
+ <!--
45
+ This is the technical portion of the feature request. Explain the design in sufficient detail that:
46
+
47
+ - Its interaction with other features is clear.
48
+ - It is reasonably clear how the feature would be implemented.
49
+ - Corner cases are dissected by example.
50
+
51
+ If you do not know how to answer this, you can omit it. No worries!
52
+ -->
53
+
54
+ ## Drawbacks
55
+
56
+ <!--
57
+ Why should we *not* do this?
58
+ -->
59
+
60
+ ## Unresolved Questions
61
+
62
+ <!--
63
+ What related issues do you consider out of scope for this feature that could be addressed in the future independently of the solution that comes out of this feature?
64
+ -->
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: Question
3
+ about: Have any questions about how UFO works?
4
+ title: ''
5
+ labels: 'question'
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ The UFO issue tracker IS NOT for usage questions! Please post your question on our dedicated forum at https://community.boltops.com
11
+
12
+ To be sensitive to everyone's time, we may close issues asking questions without comment. If you repeatedly post questions in the issues tracker, you may be blocked from ever submitting issues to UFO again. Please use your best judgment. 👍
13
+
14
+ Posting your questions in the UFO community forum benefits others by grouping questions in a dedicated place. Here are some additional options also https://ufoships.com/support/ 😁
@@ -0,0 +1,7 @@
1
+ Please fill out one of the templates on https://github.com/boltops-tools/ufo/issues/new/choose
2
+
3
+ If you want to ask a question please do so in the UFO category in the BoltOps Community forum: https://community.boltops.com
4
+
5
+ To be sensitive to everyone's time, we may close issues asking questions without comment. Posting your questions in the UFO community forum is the best place. It also benefits others by making the questions easier to find. Here are some additional options also https://ufoships.com/support/ 👌
6
+
7
+ Thank you!
@@ -0,0 +1,50 @@
1
+ <!--
2
+ Thanks for creating a Pull Request! Before you submit, please make sure you've done the following:
3
+
4
+ - I read the contributing document at https://ufoships.com/docs/contributing/
5
+ -->
6
+
7
+ <!--
8
+ Make our lives easier! Choose one of the following by uncommenting it:
9
+ -->
10
+
11
+ <!-- This is a 🐞 bug fix. -->
12
+ <!-- This is a 🙋‍♂️ feature or enhancement. -->
13
+ <!-- This is a 🧐 documentation change. -->
14
+
15
+ <!--
16
+ Before you submit this pull request, make sure to have a look at the following checklist. To mark a checkbox done, replace [ ] with [x]. Or after you create the issue you can click the checkbox.
17
+
18
+ If you don't know how to do some of these, that's fine! Submit your pull request and we will help you out on the way.
19
+ -->
20
+
21
+ - [ ] I've added tests (if it's a bug, feature or enhancement)
22
+ - [ ] I've adjusted the documentation (if it's a feature or enhancement)
23
+ - [ ] The test suite passes (run `bundle exec rspec` to verify this)
24
+
25
+ ## Summary
26
+
27
+ <!--
28
+ Provide a description of what your pull request changes.
29
+ -->
30
+
31
+ ## Context
32
+
33
+ <!--
34
+ Is this related to any GitHub issue(s) or another relevant link?
35
+ -->
36
+
37
+ ## How to Test
38
+
39
+ <!--
40
+ Please provide instructions on how to test the fix. This speeds up reviewing the PR. If testing requires a demo UFO project, please provide an example repo.
41
+ -->
42
+
43
+
44
+ ## Version Changes
45
+
46
+ <!--
47
+ Which semantic version change would you recommend?
48
+ If you don't know, feel free to omit it.
49
+ -->
50
+
data/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
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
+ ## [6.2.2] - 2022-03-20
7
+ - [#155](https://github.com/tongueroo/ufo/pull/155) layering.show option ability to show layers
8
+ - [#156](https://github.com/tongueroo/ufo/pull/156) extra layering support
9
+
10
+ ## [6.2.1] - 2022-03-16
11
+ - [#153](https://github.com/tongueroo/ufo/pull/153) dockerfile_port also consider Dockerfile.base
12
+ - [#154](https://github.com/tongueroo/ufo/pull/154) report wrong vpc config errors to user
13
+
14
+ ## [6.2.0] - 2022-03-16
15
+ - [#152](https://github.com/tongueroo/ufo/pull/152) ufo docker base: s3 storage support
16
+
6
17
  ## [6.1.5] - 2022-03-16
7
18
  - [#151](https://github.com/tongueroo/ufo/pull/151) fix symlink when .git ext is in the repo
8
19
 
@@ -0,0 +1,55 @@
1
+ require "cfn_status"
2
+
3
+ module Ufo::AwsServices
4
+ module Concerns
5
+ extend Memoist
6
+
7
+ def find_stack(stack_name)
8
+ resp = cfn.describe_stacks(stack_name: stack_name)
9
+ resp.stacks.first
10
+ rescue Aws::CloudFormation::Errors::ValidationError => e
11
+ # example: Stack with id demo-web does not exist
12
+ if e.message =~ /Stack with/ && e.message =~ /does not exist/
13
+ nil
14
+ else
15
+ raise
16
+ end
17
+ end
18
+
19
+ def stack_resources(stack_name)
20
+ resp = cfn.describe_stack_resources(stack_name: stack_name)
21
+ resp.stack_resources
22
+ rescue Aws::CloudFormation::Errors::ValidationError => e
23
+ e.message.include?("does not exist") ? return : raise
24
+ end
25
+
26
+ def task_definition_arns(family, max_items=10)
27
+ resp = ecs.list_task_definitions(
28
+ family_prefix: family,
29
+ sort: "DESC",
30
+ )
31
+ arns = resp.task_definition_arns
32
+ arns = arns.select do |arn|
33
+ task_definition = arn.split('/').last.split(':').first
34
+ task_definition == family
35
+ end
36
+ arns[0..max_items]
37
+ end
38
+
39
+ def status
40
+ CfnStatus.new(@stack_name) # NOTE: @stack_name must be set in the including Class
41
+ end
42
+ memoize :status
43
+
44
+ def find_stack_resources(stack_name)
45
+ resp = cfn.describe_stack_resources(stack_name: stack_name)
46
+ resp.stack_resources
47
+ rescue Aws::CloudFormation::Errors::ValidationError => e
48
+ if e.message.include?("does not exist")
49
+ nil
50
+ else
51
+ raise
52
+ end
53
+ end
54
+ end
55
+ end
@@ -6,15 +6,16 @@ require "aws-sdk-ec2"
6
6
  require "aws-sdk-ecr"
7
7
  require "aws-sdk-ecs"
8
8
  require "aws-sdk-elasticloadbalancingv2"
9
+ require "aws-sdk-s3"
9
10
  require "aws-sdk-ssm"
10
11
  require "aws-sdk-wafv2"
11
12
 
12
13
  require "aws_mfa_secure/ext/aws" # add MFA support
13
- require "cfn_status"
14
14
 
15
15
  module Ufo
16
16
  module AwsServices
17
17
  extend Memoist
18
+ include Concerns
18
19
 
19
20
  def acm
20
21
  Aws::ACM::Client.new(aws_options)
@@ -26,10 +27,10 @@ module Ufo
26
27
  end
27
28
  memoize :applicationautoscaling
28
29
 
29
- def cloudformation
30
+ def cfn
30
31
  Aws::CloudFormation::Client.new(aws_options)
31
32
  end
32
- memoize :cloudformation
33
+ memoize :cfn
33
34
 
34
35
  def cloudwatchlogs
35
36
  Aws::CloudWatchLogs::Client.new(aws_options)
@@ -56,6 +57,11 @@ module Ufo
56
57
  end
57
58
  memoize :elb
58
59
 
60
+ def s3
61
+ Aws::S3::Client.new(aws_options)
62
+ end
63
+ memoize :s3
64
+
59
65
  # ssm is a helper method
60
66
  def ssm_client
61
67
  Aws::SSM::Client.new(aws_options)
@@ -98,42 +104,5 @@ module Ufo
98
104
  ) if ENV['UFO_DEBUG_AWS_SDK']
99
105
  options
100
106
  end
101
-
102
- def find_stack(stack_name)
103
- resp = cloudformation.describe_stacks(stack_name: stack_name)
104
- resp.stacks.first
105
- rescue Aws::CloudFormation::Errors::ValidationError => e
106
- # example: Stack with id demo-web does not exist
107
- if e.message =~ /Stack with/ && e.message =~ /does not exist/
108
- nil
109
- else
110
- raise
111
- end
112
- end
113
-
114
- def stack_resources(stack_name)
115
- resp = cloudformation.describe_stack_resources(stack_name: stack_name)
116
- resp.stack_resources
117
- rescue Aws::CloudFormation::Errors::ValidationError => e
118
- e.message.include?("does not exist") ? return : raise
119
- end
120
-
121
- def task_definition_arns(family, max_items=10)
122
- resp = ecs.list_task_definitions(
123
- family_prefix: family,
124
- sort: "DESC",
125
- )
126
- arns = resp.task_definition_arns
127
- arns = arns.select do |arn|
128
- task_definition = arn.split('/').last.split(':').first
129
- task_definition == family
130
- end
131
- arns[0..max_items]
132
- end
133
-
134
- def status
135
- CfnStatus.new(@stack_name) # NOTE: @stack_name must be set in the including Class
136
- end
137
- memoize :status
138
107
  end
139
108
  end
@@ -9,6 +9,7 @@ class Ufo::Cfn::Stack
9
9
  end
10
10
 
11
11
  def build
12
+ logger.info "Building template"
12
13
  @template[:Parameters] = Parameters.build(@options)
13
14
  @template[:Conditions] = Conditions.build(@options)
14
15
  @template[:Resources] = Resources.build(@options)
@@ -23,7 +24,7 @@ class Ufo::Cfn::Stack
23
24
  text = YAML.dump(template)
24
25
  path = ".ufo/output/template.yml"
25
26
  IO.write("#{Ufo.root}/#{path}", text)
26
- logger.info "Template built: #{path}"
27
+ logger.info " #{path}"
27
28
  # Only basic YAML validation. Doesnt check for everything CloudFormation checks.
28
29
  # For CloudFormation checks handled with an exception handler in Cfn::Stack#print_code(exception)
29
30
  Ufo::Yaml.validate!(path)
@@ -1,6 +1,7 @@
1
1
  class Ufo::Cfn::Stack
2
2
  class Params < Ufo::Cfn::Stack::Builder::Base
3
3
  def build
4
+ logger.info "Building params"
4
5
  params = {
5
6
  Vpc: vpc.id,
6
7
  ElbSubnets: vpc.elb_subnets,
@@ -40,7 +41,7 @@ class Ufo::Cfn::Stack
40
41
  path = "#{Ufo.root}/.ufo/output/params.json"
41
42
  FileUtils.mkdir_p(File.dirname(path))
42
43
  IO.write(path, JSON.pretty_generate(params))
43
- logger.info "Parameters built: #{pretty_path(path)}"
44
+ logger.info " #{pretty_path(path)}"
44
45
  end
45
46
 
46
47
  def vpc
@@ -122,7 +122,7 @@ class Ufo::Cfn::Stack
122
122
 
123
123
  # refreshes the loaded events in memory
124
124
  def refresh_events
125
- resp = cloudformation.describe_stack_events(stack_name: @stack_name)
125
+ resp = cfn.describe_stack_events(stack_name: @stack_name)
126
126
  @events = resp["stack_events"]
127
127
  rescue Aws::CloudFormation::Errors::ValidationError => e
128
128
  if e.message =~ /Stack .* does not exis/
data/lib/ufo/cfn/stack.rb CHANGED
@@ -31,7 +31,7 @@ module Ufo::Cfn
31
31
  @stack = find_stack(@stack_name)
32
32
  if @stack && rollback_complete?(@stack)
33
33
  logger.info "Existing stack in ROLLBACK_COMPLETE state. Deleting stack before continuing."
34
- cloudformation.delete_stack(stack_name: @stack_name)
34
+ cfn.delete_stack(stack_name: @stack_name)
35
35
  status.wait
36
36
  status.reset
37
37
  @stack = nil # at this point stack has been deleted
@@ -53,7 +53,7 @@ module Ufo::Cfn
53
53
 
54
54
  def perform(action)
55
55
  logger.info "#{action[0..-2].capitalize}ing stack #{@stack_name.color(:green)}"
56
- cloudformation.send("#{action}_stack", stack_options) # Example: cloudformation.send("update_stack", stack_options)
56
+ cfn.send("#{action}_stack", stack_options) # Example: cfn.send("update_stack", stack_options)
57
57
  rescue Aws::CloudFormation::Errors::ValidationError => e
58
58
  handle_stack_error(e)
59
59
  end
@@ -152,10 +152,10 @@ module Ufo::Cfn
152
152
  end
153
153
 
154
154
  if stack.stack_status == "CREATE_IN_PROGRESS"
155
- cloudformation.delete_stack(stack_name: @stack_name)
155
+ cfn.delete_stack(stack_name: @stack_name)
156
156
  logger.info "Canceling stack creation"
157
157
  elsif stack.stack_status == "UPDATE_IN_PROGRESS"
158
- cloudformation.cancel_update_stack(stack_name: @stack_name)
158
+ cfn.cancel_update_stack(stack_name: @stack_name)
159
159
  logger.info "Canceling stack update"
160
160
  else
161
161
  logger.info "The stack is not in a state to that is cancelable: #{stack.stack_status}"
@@ -17,7 +17,7 @@ class Ufo::CLI
17
17
  return
18
18
  end
19
19
 
20
- cloudformation.delete_stack(stack_name: @stack_name)
20
+ cfn.delete_stack(stack_name: @stack_name)
21
21
  puts "Deleting stack #{@stack_name.color(:green)}"
22
22
 
23
23
  return unless @options[:wait]
@@ -15,6 +15,7 @@ class Ufo::CLI::Ps
15
15
  scale
16
16
  target_group
17
17
  deployment_configuration
18
+ wrong_vpc
18
19
  catchall
19
20
  end
20
21
 
@@ -86,6 +87,45 @@ class Ufo::CLI::Ps
86
87
  EOL
87
88
  end
88
89
 
90
+ # To reproduce #1
91
+ #
92
+ # 1. Deploy to with settings where ECS cluster is in custom VPC successfully
93
+ # 2. Deploy again. Accidentally with default VPC settings <= Reproduction
94
+ #
95
+ # This will produce a CloudFormation stack failure
96
+ #
97
+ # > All subnets must belong to the same VPC: 'vpc-11111111' (Service: AmazonElasticLoadBalancing; Status Code: 400; Error Code: InvalidConfigurationRequest; Request ID: b8c683ca-4c6d-4bf9-bf9b-3eb468fa9ea9; Proxy: null)
98
+ #
99
+ # So it's not actually an ECS failure and is caught early on. Notiing it for posterity.
100
+ #
101
+ # To reproduce #2
102
+ #
103
+ # Deploy to default VPC. Even though ECS cluster is running on a custom VPC <= Reproduction
104
+ #
105
+ # This reproduces:
106
+ #
107
+ # > ERROR: (service demo-web-dev-EcsService-RkMBAhHBfx9A) failed to register targets in (target-group arn:aws:elasticloadbalancing:us-west-2:111111111111:targetgroup/demo-Targe-1HEN2QPS5LO9B/0c69c3eb5aa23bc9) with (error The following targets are not in the target group VPC 'vpc-11111111': 'i-11111111111111111')
108
+ #
109
+ # The first deploy suceeeds because CloudFormation doesn't check on the ECS service as much here.
110
+ # ECS does report the error though.
111
+ #
112
+ def wrong_vpc
113
+ error_event = recent_events.find do |e|
114
+ e.message =~ /targets are not in the target group VPC/ ||
115
+ e.message =~ /All subnets must belong to the same VPC/
116
+ end
117
+ return unless error_event
118
+
119
+ logger.info "ERROR: VPC Configuration error".color(:red)
120
+ logger.info error_event.message.color(:red)
121
+ logger.info <<~EOL
122
+ It seems like the ECS Service was deployed to an ECS Cluster running on
123
+ a different VPC than what's the ECS Service is configured with.
124
+
125
+ See: https://ufoships.com/docs/debug/vpc-subnets/
126
+ EOL
127
+ end
128
+
89
129
  # Example:
90
130
  # (service app1-web-dev-EcsService-8FMliG8m6M2p) was unable to stop or start tasks during a deployment because of the service deployment configuration. Update the minimumHealthyPercent or maximumPercent value and try again.
91
131
  def catchall
data/lib/ufo/command.rb CHANGED
@@ -39,7 +39,7 @@ module Ufo
39
39
  # This requires Ufo.role.
40
40
  # So we set Ufo.role before triggering Ufo.config loading
41
41
  check_project!(args)
42
- check_old_version_structure!(args)
42
+ check_version_structure!
43
43
  # Special case for `ufo central` commands.
44
44
  # Dont want to call configure_dsl_evaluator
45
45
  # and trigger loading of config => .ufo/config.rb
@@ -99,23 +99,33 @@ module Ufo
99
99
  return if subcommand?
100
100
  return if command_name.nil?
101
101
  return if help_flags.include?(args.last) # IE: -h help
102
- return if %w[-h -v --version central init version].include?(command_name)
102
+ return if non_project_command?
103
103
  return if File.exist?("#{Ufo.root}/.ufo")
104
104
 
105
105
  logger.error "ERROR: It doesnt look like this is a ufo project. Are you sure you are in a ufo project?".color(:red)
106
106
  ENV['UFO_TEST'] ? raise : exit(1)
107
107
  end
108
108
 
109
- def check_old_version_structure!(args)
110
- return unless File.exist?('.ufo/settings.yml')
111
- puts "ERROR: Old .ufo configurations detected".color(:red)
109
+ # Also, using ARGV instead of args because args is called by thor in multiple passes
110
+ # For `ufo central update`:
111
+ # * 1st pass: "central"
112
+ # * 2nd pass: "update"
113
+ def non_project_command?
114
+ commands = %w[-h -v --version completion completion_script help central init version]
115
+ commands.include?(ARGV[0])
116
+ end
117
+
118
+ def check_version_structure!
119
+ return if non_project_command?
120
+ return if File.exist?('.ufo/config.rb')
121
+ puts "ERROR: Latest ufo structure not detected".color(:red)
112
122
  puts <<~EOL
113
123
  It looks like this project .ufo files for an older ufo version.
114
124
  The old .ufo structure does not work with this version of ufo.
115
125
 
116
- Current Installed UFO Version: 6.0.9
126
+ Current Installed UFO Version: #{Ufo::VERSION}
117
127
 
118
- Please upgrade.
128
+ Please update the .ufo structure.
119
129
 
120
130
  See: https://ufoships.com/docs/upgrading/upgrade6/
121
131
  EOL