stack_master 1.7.2 → 1.8.0

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: 30cfadeee3e2233769778b0326dc0e5286dcc29d697453828a2b603662865962
4
- data.tar.gz: 71440c768cf83594d9181013cdd18988129d9c5916d900e98ba2b823c92dcf3a
3
+ metadata.gz: 141acaa24c68d9cfcca1bdb9f49ab0da7312d16eeee11a61d14e45d8a7e2032a
4
+ data.tar.gz: c1af824e3c84cded41092ca995cb3a2febae0ad22781ae8bda4448202602681d
5
5
  SHA512:
6
- metadata.gz: 24c2eb81da8608aece2091b5a848420ca32c77e7e8d8295a6fa033c9f950be16573bf04dae1a440ddcfaeae36df33b8a9262eccfb2c8c715d6c4b13f4cbb27d6
7
- data.tar.gz: 9638cab0d4edffe17665595bddb72eb5dcefca103b1f9e42d603368e990fc68a08018264f94d9b0a4fddc14ac2f81ab91610f135282311d64970ca872acdf675
6
+ metadata.gz: e649d82d6a5b088d71485c4c5cae8e0b379396299bed964f4792cbffa3046f1ef6e813a7f6e8d20501a4c07f0fed24dca293587b04fb5a9450c86b182a16a66c
7
+ data.tar.gz: 2495f5b12195f698f6870752eca4512ec438b4a18b41d7ee4f9696dfa5eeb2e096fa81caf964a8c8886645c7a682940fc09c420408c019c0bf3bd362be4f840e
data/README.md CHANGED
@@ -340,6 +340,15 @@ db_username:
340
340
  env: DB_USERNAME
341
341
  ```
342
342
 
343
+ ### ACM Certificates
344
+
345
+ Find an ACM certificate by domain name:
346
+
347
+ ```yaml
348
+ cert:
349
+ acm_certificate: www.example.com
350
+ ```
351
+
343
352
  ### Custom parameter resolvers
344
353
 
345
354
  New parameter resolvers can be created in a separate gem.
@@ -1,11 +1,12 @@
1
1
  require 'commander'
2
2
  require 'yaml'
3
- require "aws-sdk-cloudformation"
4
- require "aws-sdk-ec2"
5
- require "aws-sdk-s3"
6
- require "aws-sdk-sns"
7
- require "aws-sdk-ssm"
8
- require "colorize"
3
+ require 'aws-sdk-acm'
4
+ require 'aws-sdk-cloudformation'
5
+ require 'aws-sdk-ec2'
6
+ require 'aws-sdk-s3'
7
+ require 'aws-sdk-sns'
8
+ require 'aws-sdk-ssm'
9
+ require 'colorize'
9
10
  require 'active_support/core_ext/string'
10
11
  require 'multi_json'
11
12
 
@@ -54,12 +55,15 @@ module StackMaster
54
55
  autoload :Diff, 'stack_master/commands/diff'
55
56
  autoload :ListStacks, 'stack_master/commands/list_stacks'
56
57
  autoload :Validate, 'stack_master/commands/validate'
58
+ autoload :Lint, 'stack_master/commands/lint'
59
+ autoload :Compile, 'stack_master/commands/compile'
57
60
  autoload :Resources, 'stack_master/commands/resources'
58
61
  autoload :Delete, 'stack_master/commands/delete'
59
62
  autoload :Status, 'stack_master/commands/status'
60
63
  end
61
64
 
62
65
  module ParameterResolvers
66
+ autoload :AcmCertificate, 'stack_master/parameter_resolvers/acm_certificate'
63
67
  autoload :AmiFinder, 'stack_master/parameter_resolvers/ami_finder'
64
68
  autoload :StackOutput, 'stack_master/parameter_resolvers/stack_output'
65
69
  autoload :Secret, 'stack_master/parameter_resolvers/secret'
@@ -131,6 +131,28 @@ module StackMaster
131
131
  end
132
132
  end
133
133
 
134
+ command :lint do |c|
135
+ c.syntax = 'stack_master lint [region_or_alias] [stack_name]'
136
+ c.summary = "Check the stack definition locally"
137
+ c.description = "Runs cfn-lint on the template which would be sent to AWS on apply"
138
+ c.example 'run cfn-lint on stack myapp-vpc with us-east-1 settings', 'stack_master lint us-east-1 myapp-vpc'
139
+ c.action do |args, options|
140
+ options.defaults config: default_config_file
141
+ execute_stacks_command(StackMaster::Commands::Lint, args, options)
142
+ end
143
+ end
144
+
145
+ command :compile do |c|
146
+ c.syntax = 'stack_master compile [region_or_alias] [stack_name]'
147
+ c.summary = "Print the compiled version of a given stack"
148
+ c.description = "Processes the stack and prints out a compiled version - same we'd send to AWS"
149
+ c.example 'print compiled stack myapp-vpc with us-east-1 settings', 'stack_master compile us-east-1 myapp-vpc'
150
+ c.action do |args, options|
151
+ options.defaults config: default_config_file
152
+ execute_stacks_command(StackMaster::Commands::Compile, args, options)
153
+ end
154
+ end
155
+
134
156
  command :status do |c|
135
157
  c.syntax = 'stack_master status'
136
158
  c.summary = 'Check the current status stacks.'
@@ -0,0 +1,27 @@
1
+ module StackMaster
2
+ module Commands
3
+ class Compile
4
+ include Command
5
+ include Commander::UI
6
+
7
+ def initialize(config, stack_definition, options = {})
8
+ @config = config
9
+ @stack_definition = stack_definition
10
+ end
11
+
12
+ def perform
13
+ puts(proposed_stack.template_body)
14
+ end
15
+
16
+ private
17
+
18
+ def stack_definition
19
+ @stack_definition ||= @config.find_stack(@region, @stack_name)
20
+ end
21
+
22
+ def proposed_stack
23
+ @proposed_stack ||= Stack.generate(stack_definition, @config)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,42 @@
1
+ require 'tempfile'
2
+
3
+ module StackMaster
4
+ module Commands
5
+ class Lint
6
+ include Command
7
+ include Commander::UI
8
+
9
+ def initialize(config, stack_definition, options = {})
10
+ @config = config
11
+ @stack_definition = stack_definition
12
+ end
13
+
14
+ def perform
15
+ unless cfn_lint_available
16
+ failed! "Failed to run cfn-lint, do you have it installed and available in $PATH?"
17
+ end
18
+
19
+ Tempfile.open(['stack', ".#{proposed_stack.template_format}"]) do |f|
20
+ f.write(proposed_stack.template_body)
21
+ f.flush
22
+ system('cfn-lint', f.path)
23
+ puts "cfn-lint run complete"
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def stack_definition
30
+ @stack_definition ||= @config.find_stack(@region, @stack_name)
31
+ end
32
+
33
+ def proposed_stack
34
+ @proposed_stack ||= Stack.generate(stack_definition, @config)
35
+ end
36
+
37
+ def cfn_lint_available
38
+ !system('cfn-lint', '--version').nil?
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,37 @@
1
+ module StackMaster
2
+ module ParameterResolvers
3
+ class AcmCertificate < Resolver
4
+ CertificateNotFound = Class.new(StandardError)
5
+
6
+ def initialize(config, stack_definition)
7
+ @config = config
8
+ @stack_definition = stack_definition
9
+ end
10
+
11
+ def resolve(domain_name)
12
+ cert_arn = find_cert_arn_by_domain_name(domain_name)
13
+ raise CertificateNotFound, "Could not find certificate #{domain_name} in #{@stack_definition.region}" unless cert_arn
14
+ cert_arn
15
+ end
16
+
17
+ private
18
+
19
+ def all_certs
20
+ certs = []
21
+ next_token = nil
22
+ client = Aws::ACM::Client.new(region: @stack_definition.region)
23
+ loop do
24
+ resp = client.list_certificates(certificate_statuses: ['ISSUED'], next_token: next_token)
25
+ certs << resp.certificate_summary_list
26
+ next_token = resp.next_token
27
+ break if next_token.nil?
28
+ end
29
+ certs.flatten
30
+ end
31
+
32
+ def find_cert_arn_by_domain_name(domain_name)
33
+ all_certs.map { |c| c.certificate_arn if c.domain_name == domain_name }.compact.first
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module StackMaster
2
- VERSION = "1.7.2"
2
+ VERSION = "1.8.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stack_master
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Hodgkiss
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-07-05 00:00:00.000000000 Z
12
+ date: 2018-07-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -151,6 +151,20 @@ dependencies:
151
151
  - - ">="
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
+ - !ruby/object:Gem::Dependency
155
+ name: aws-sdk-acm
156
+ requirement: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: '1'
161
+ type: :runtime
162
+ prerelease: false
163
+ version_requirements: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '1'
154
168
  - !ruby/object:Gem::Dependency
155
169
  name: aws-sdk-cloudformation
156
170
  requirement: !ruby/object:Gem::Requirement
@@ -379,10 +393,12 @@ files:
379
393
  - lib/stack_master/cli.rb
380
394
  - lib/stack_master/command.rb
381
395
  - lib/stack_master/commands/apply.rb
396
+ - lib/stack_master/commands/compile.rb
382
397
  - lib/stack_master/commands/delete.rb
383
398
  - lib/stack_master/commands/diff.rb
384
399
  - lib/stack_master/commands/events.rb
385
400
  - lib/stack_master/commands/init.rb
401
+ - lib/stack_master/commands/lint.rb
386
402
  - lib/stack_master/commands/list_stacks.rb
387
403
  - lib/stack_master/commands/outputs.rb
388
404
  - lib/stack_master/commands/resources.rb
@@ -394,6 +410,7 @@ files:
394
410
  - lib/stack_master/paged_response_accumulator.rb
395
411
  - lib/stack_master/parameter_loader.rb
396
412
  - lib/stack_master/parameter_resolver.rb
413
+ - lib/stack_master/parameter_resolvers/acm_certificate.rb
397
414
  - lib/stack_master/parameter_resolvers/ami_finder.rb
398
415
  - lib/stack_master/parameter_resolvers/env.rb
399
416
  - lib/stack_master/parameter_resolvers/latest_ami.rb