moonshot 2.0.0.beta7 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bacc77a06be77c55f7f4e73d73d9e62cdccf5b9fbb8187026f0e0ae1cc3c4732
4
- data.tar.gz: 27d5031220c00c7a1abc4653c2280223d1f74a4d38c285cd77da8cb743cb2257
3
+ metadata.gz: d87f616758ca8f4b32b4af436e73c565665b8753d38b3fd14d478f6a6d347ce4
4
+ data.tar.gz: 616b51d3d59341f58beb48efea6af2dba7a3821ef0dace26f4dd1eae395a34bf
5
5
  SHA512:
6
- metadata.gz: b734d33a71f63b80962adb425438c0ece07baba1a0cb66c8a6b8b1be337991438bf427ce1d80582502d3b4ff6ab6e12bfe45df927731a17ddd3ff4961c9178d8
7
- data.tar.gz: de00cd0374f40133d472808c67dc32049c276ea79e4200ea6a471a67b2d831747596b2659f8669009532211ac0851cde1bc36cd91510d41917e8db4446308994
6
+ metadata.gz: 8532967756fa789d68ce86fbdffc25bb053f5c483d784285b43ed1c934c40d72c03dc3ec73674bb6d06eb58bf2ec3b6f3641156ea6f7797e387e3d16ecf3ecc8
7
+ data.tar.gz: a4bcf9e2b1d6367670aa7cba505d4d561231d114dce658c2a92b10786f8eae24c25ba7052057966e5d6c8a5569633f4676eedda7d198483f7ef0c9446bd132da
@@ -77,9 +77,17 @@ module Moonshot
77
77
  end
78
78
 
79
79
  def wait_for_change_set
80
- @cf_client.wait_until(:change_set_create_complete,
81
- stack_name: @stack_name,
82
- change_set_name: @name)
80
+ begin
81
+ @cf_client.wait_until(:change_set_create_complete,
82
+ stack_name: @stack_name,
83
+ change_set_name: @name)
84
+ rescue Aws::Waiters::Errors::FailureStateError => e
85
+ if e.message != 'stopped waiting, encountered a failure state'
86
+ throw e
87
+ else
88
+ puts "The change set didn't contain any new changes."
89
+ end
90
+ end
83
91
 
84
92
  @change_set = @cf_client.describe_change_set(stack_name: @stack_name,
85
93
  change_set_name: @name)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'parameter_arguments'
4
+ require_relative 'tag_arguments'
4
5
  require_relative 'show_all_events_option'
5
6
  require_relative 'parent_stack_option'
6
7
 
@@ -8,6 +9,7 @@ module Moonshot
8
9
  module Commands
9
10
  class Create < Moonshot::Command
10
11
  include ParameterArguments
12
+ include TagArguments
11
13
  include ShowAllEventsOption
12
14
  include ParentStackOption
13
15
 
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Moonshot
4
+ module Commands
5
+ module TagArguments
6
+ def parser
7
+ parser = super
8
+
9
+ parser.on('--tag KEY=VALUE', '-TKEY=VALUE', 'Specify Stack Tag on the command line') do |v|
10
+ data = v.split('=', 2)
11
+ unless data.size == 2
12
+ raise "Invalid tag format '#{v}', expected KEY=VALUE (e.g. MyStackTag=12)"
13
+ end
14
+
15
+ Moonshot.config.extra_tags << { key: data[0], value: data[1] }
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -4,6 +4,7 @@ module Moonshot
4
4
  module Commands
5
5
  class Update < Moonshot::Command
6
6
  include ParameterArguments
7
+ include TagArguments
7
8
  include ShowAllEventsOption
8
9
  include ParentStackOption
9
10
 
@@ -10,7 +10,7 @@ module Moonshot
10
10
  :interactive, :interactive_logger, :parameter_overrides, :parameters, :parent_stacks,
11
11
  :default_parameter_source, :parameter_sources, :plugins, :project_root,
12
12
  :show_all_stack_events, :ssh_auto_scaling_group_name, :ssh_command, :ssh_config,
13
- :ssh_instance, :template_file, :template_s3_bucket
13
+ :ssh_instance, :template_file, :template_s3_bucket, :extra_tags
14
14
 
15
15
  def initialize
16
16
  @default_parameter_source = AskUserSource.new
@@ -26,6 +26,7 @@ module Moonshot
26
26
  @project_root = Dir.pwd
27
27
  @show_all_stack_events = false
28
28
  @ssh_config = SSHConfig.new
29
+ @extra_tags = []
29
30
 
30
31
  @dev_build_name_proc = lambda do |c|
31
32
  ['dev', c.app_name, c.environment_name, Time.now.to_i].join('/')
@@ -13,10 +13,30 @@ module Moonshot
13
13
 
14
14
  attr_reader :app_name, :name
15
15
 
16
+ class << self
17
+ def generate_name(config)
18
+ [config.app_name, config.environment_name].join('-')
19
+ end
20
+
21
+ def make_tags(config)
22
+ default_tags = [
23
+ { key: 'moonshot_application', value: config.app_name },
24
+ { key: 'moonshot_environment', value: config.environment_name }
25
+ ]
26
+ name = generate_name(config)
27
+
28
+ if config.additional_tag
29
+ default_tags << { key: config.additional_tag, value: name }
30
+ end
31
+
32
+ default_tags + config.extra_tags
33
+ end
34
+ end
35
+
16
36
  def initialize(config)
17
37
  @config = config
18
38
  @ilog = config.interactive_logger
19
- @name = [@config.app_name, @config.environment_name].join('-')
39
+ @name = self.class.generate_name(@config)
20
40
 
21
41
  yield @config if block_given?
22
42
  end
@@ -233,8 +253,9 @@ module Moonshot
233
253
  change_set_name:,
234
254
  description: "Moonshot update command for application '#{Moonshot.config.app_name}'",
235
255
  stack_name: @name,
236
- capabilities: %w[CAPABILITY_IAM CAPABILITY_NAMED_IAM],
237
- parameters: @config.parameters.values.map(&:to_cf)
256
+ capabilities: %w(CAPABILITY_IAM CAPABILITY_NAMED_IAM), # rubocop:disable Layout/HashAlignment,Style/PercentLiteralDelimiters
257
+ parameters: @config.parameters.values.map(&:to_cf),
258
+ tags: make_tags
238
259
  }
239
260
  if @config.template_s3_bucket
240
261
  parameters[:template_url] = upload_template_to_s3
@@ -288,14 +309,7 @@ module Moonshot
288
309
  end
289
310
 
290
311
  def make_tags
291
- default_tags = [
292
- { key: 'moonshot_application', value: @config.app_name },
293
- { key: 'moonshot_environment', value: @config.environment_name }
294
- ]
295
-
296
- default_tags << { key: @config.additional_tag, value: @name } if @config.additional_tag
297
-
298
- default_tags
312
+ self.class.make_tags(@config)
299
313
  end
300
314
 
301
315
  def format_event(event)
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'aws-sdk-elasticloadbalancing'
4
+ require 'aws-sdk-autoscaling'
5
+
3
6
  module Moonshot
4
7
  module Tools
5
8
  class ASGRollout
@@ -37,12 +37,14 @@ module Moonshot
37
37
  end
38
38
 
39
39
  def draw(depth = 1, first = true)
40
+ space = ' '
41
+ pipe = '|'
40
42
  print first ? '┌' : '├'
41
43
  print '─' * depth
42
- puts ' ' << @name.light_black
44
+ puts "#{space}" << @name.light_black # rubocop:disable Style/RedundantInterpolation
43
45
  @lines = [''] + @lines + ['']
44
46
  @lines.each do |line|
45
- puts '│' << (' ' * depth) << line
47
+ puts "#{pipe}" << (' ' * depth) << line # rubocop:disable Style/RedundantInterpolation
46
48
  end
47
49
  @children.each do |child|
48
50
  child.draw(depth + 1, false)
@@ -200,7 +200,7 @@ module Moonshot
200
200
  # single bucket for all accounts
201
201
  return @bucket if @bucket
202
202
  # calculating bucket based on account name
203
- return bucket_by_account(iam_account) if @buckets
203
+ return bucket_by_account(iam_account) if @buckets # rubocop:disable Style/RedundantReturn
204
204
  end
205
205
 
206
206
  def bucket_by_account(account)
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative '../../moonshot/stack'
4
+
3
5
  module Moonshot
4
6
  module Plugins
5
7
  class EncryptedParameters
@@ -7,16 +9,33 @@ module Moonshot
7
9
  class KmsKey
8
10
  attr_reader :arn
9
11
 
12
+ class << self
13
+ def create
14
+ standard_tags = stack_tags
15
+ resp = Aws::KMS::Client.new.create_key({
16
+ tags: standard_tags # An array of tags.
17
+ })
18
+ arn = resp.key_metadata.arn
19
+ new(arn)
20
+ end
21
+
22
+ def stack_tags
23
+ tags = Moonshot::Stack.make_tags(Moonshot.config)
24
+ tags.map { |tag| { tag_key: tag[:key], tag_value: tag[:value] } }
25
+ end
26
+ end
27
+
10
28
  def initialize(arn)
11
29
  @arn = arn
12
30
  @kms_client = Aws::KMS::Client.new
13
31
  end
14
32
 
15
- def self.create
16
- resp = Aws::KMS::Client.new.create_key
17
- arn = resp.key_metadata.arn
18
-
19
- new(arn)
33
+ def update
34
+ standard_tags = self.class.stack_tags
35
+ @kms_client.tag_resource({
36
+ key_id: @arn, # arn of the CMK being tagged
37
+ tags: standard_tags # An array of tags.
38
+ })
20
39
  end
21
40
 
22
41
  def delete
@@ -104,7 +104,9 @@ module Moonshot
104
104
  Moonshot.config.parameters[@kms_key_parameter_name].set(key_arn)
105
105
  s.success "Created a new KMS Key for #{@kms_key_parameter_name.blue}!"
106
106
  else
107
- key_arn = KmsKey.new(Moonshot.config.parameters[@kms_key_parameter_name].value).arn
107
+ kms=KmsKey.new(Moonshot.config.parameters[@kms_key_parameter_name].value) # rubocop:disable Style/SpaceAroundOperators
108
+ key_arn = kms.arn
109
+ kms.update
108
110
  s.success "Using existing KMS Key for #{@kms_key_parameter_name.blue}!"
109
111
  end
110
112
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moonshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta7
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cloud Engineering <engineering@acquia.com>
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-23 00:00:00.000000000 Z
11
+ date: 2024-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-autoscaling
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.34'
69
+ - !ruby/object:Gem::Dependency
70
+ name: aws-sdk-elasticloadbalancing
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: aws-sdk-iam
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,48 @@ dependencies:
122
136
  - - ">="
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: faraday
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: faraday-rack
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 1.0.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 1.0.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: faraday-retry
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '1.0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '1.0'
125
181
  - !ruby/object:Gem::Dependency
126
182
  name: highline
127
183
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +248,20 @@ dependencies:
192
248
  - - ">="
193
249
  - !ruby/object:Gem::Version
194
250
  version: '0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: rexml
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ type: :runtime
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
195
265
  - !ruby/object:Gem::Dependency
196
266
  name: rotp
197
267
  requirement: !ruby/object:Gem::Requirement
@@ -252,16 +322,16 @@ dependencies:
252
322
  name: travis
253
323
  requirement: !ruby/object:Gem::Requirement
254
324
  requirements:
255
- - - ">="
325
+ - - "~>"
256
326
  - !ruby/object:Gem::Version
257
- version: '0'
327
+ version: 1.11.1
258
328
  type: :runtime
259
329
  prerelease: false
260
330
  version_requirements: !ruby/object:Gem::Requirement
261
331
  requirements:
262
- - - ">="
332
+ - - "~>"
263
333
  - !ruby/object:Gem::Version
264
- version: '0'
334
+ version: 1.11.1
265
335
  - !ruby/object:Gem::Dependency
266
336
  name: vandamme
267
337
  requirement: !ruby/object:Gem::Requirement
@@ -360,6 +430,7 @@ files:
360
430
  - lib/moonshot/commands/show_all_events_option.rb
361
431
  - lib/moonshot/commands/ssh.rb
362
432
  - lib/moonshot/commands/status.rb
433
+ - lib/moonshot/commands/tag_arguments.rb
363
434
  - lib/moonshot/commands/update.rb
364
435
  - lib/moonshot/commands/version.rb
365
436
  - lib/moonshot/config.rb
@@ -418,12 +489,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
418
489
  requirements:
419
490
  - - ">="
420
491
  - !ruby/object:Gem::Version
421
- version: 3.1.3
492
+ version: 3.3.4
422
493
  required_rubygems_version: !ruby/object:Gem::Requirement
423
494
  requirements:
424
- - - ">"
495
+ - - ">="
425
496
  - !ruby/object:Gem::Version
426
- version: 1.3.1
497
+ version: '0'
427
498
  requirements: []
428
499
  rubygems_version: 3.1.6
429
500
  signing_key: