aws-sdk-utils 0.0.13 → 0.0.14

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e8fbf062269b50c357e7d0d2c7b3217dc23e5d6
4
- data.tar.gz: 2154657b6fc1aef662c5ca91067f8cd994b77ee9
3
+ metadata.gz: 56b88ff3bfe2bbd37bb26d95ae9afde69be8175c
4
+ data.tar.gz: b36cc9d7abefb490f01ef62ce5a61dd411ab02b1
5
5
  SHA512:
6
- metadata.gz: 19a8b56ebf31de6998b580a81b006945432e174aa074b7dd38464bf9c83fa4f517931d465f5ac6e8133856967536eba5c381dbe33e41aa8d41775a055af12461
7
- data.tar.gz: 87ad63032d0262343c043622f98c12c6732970d2e68b9a0483c7341325ba8a19d8a5b94a284087ca2f474308c8e361b93ab5ff04de77eadbe6b56267f1a929f2
6
+ metadata.gz: 4df4a55f0e96dfc4545eea0cf02ffd84c91c54821e98a5317b95d81b7d3503acd4b120d422bdc63c185c73c13887e9401c8fc539a6e958e1b50ce6f424e687e4
7
+ data.tar.gz: 67f261017b5109ce12a659b48f62305cd509d512053a474a8e0c69b9ac42898856b79ffcca88c15e0038ceb109e05f714347f20dcf88026e1ec25de58ec535cf
@@ -7,6 +7,7 @@ opts = Trollop::options do
7
7
  opt :path_to_stack, '', type: :string, required: true
8
8
  opt :stack_name, '', type: :string, required: true
9
9
  opt :path_to_yaml, '', type: :string, required: false
10
+ opt :strip_extra_parameters, '', type: :boolean, required: false, default: false
10
11
  end
11
12
 
12
13
  bindings = opts[:path_to_yaml].nil? ? nil : YAML.load_file(opts[:path_to_yaml])
@@ -14,7 +15,8 @@ bindings = opts[:path_to_yaml].nil? ? nil : YAML.load_file(opts[:path_to_yaml])
14
15
  begin
15
16
  outputs = CloudFormationConverger.new.converge(stack_name: opts[:stack_name],
16
17
  stack_path: opts[:path_to_stack],
17
- bindings: bindings)
18
+ bindings: bindings,
19
+ strip_extras: opts[:strip_extra_parameters])
18
20
 
19
21
  puts outputs.to_yaml
20
22
  rescue Exception => e
@@ -5,14 +5,19 @@ class CloudFormationConverger
5
5
 
6
6
  def converge(stack_name:,
7
7
  stack_path:,
8
- bindings: nil)
8
+ bindings: nil,
9
+ strip_extras: false)
10
+
11
+ cloudformation_client = Aws::CloudFormation::Client.new
12
+
13
+ validate_template_response = cloudformation_client.validate_template(template_body: IO.read(stack_path))
14
+ legal_parameters = validate_template_response.parameters.map { | parameter| parameter.parameter_key }
9
15
 
10
16
  parameters = []
11
17
  unless bindings.nil?
12
- parameters = convert_hash_to_parameters bindings
18
+ parameters = convert_hash_to_parameters bindings, legal_parameters, strip_extras
13
19
  end
14
20
 
15
- cloudformation_client = Aws::CloudFormation::Client.new
16
21
  resource = Aws::CloudFormation::Resource.new(client: cloudformation_client)
17
22
  if resource.stacks.find {|stack| stack.name == stack_name }
18
23
  stack = resource.stack(stack_name)
@@ -51,14 +56,26 @@ class CloudFormationConverger
51
56
 
52
57
  private
53
58
 
54
- def convert_hash_to_parameters(hash)
59
+ def convert_hash_to_parameters(hash,
60
+ legal_parameters,
61
+ strip_extras)
55
62
  parameters = []
56
63
  hash.each do |k,v|
57
- parameters << {
58
- parameter_key: k,
59
- parameter_value: v,
60
- use_previous_value: false
61
- }
64
+ if strip_extras
65
+ if legal_parameters.include? k
66
+ parameters << {
67
+ parameter_key: k,
68
+ parameter_value: v,
69
+ use_previous_value: false
70
+ }
71
+ end
72
+ else
73
+ parameters << {
74
+ parameter_key: k,
75
+ parameter_value: v,
76
+ use_previous_value: false
77
+ }
78
+ end
62
79
  end
63
80
  parameters
64
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - someguy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-21 00:00:00.000000000 Z
11
+ date: 2016-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk