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 +4 -4
- data/bin/cfn_converge +3 -1
- data/lib/cloudformation_converger.rb +26 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56b88ff3bfe2bbd37bb26d95ae9afde69be8175c
|
4
|
+
data.tar.gz: b36cc9d7abefb490f01ef62ce5a61dd411ab02b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4df4a55f0e96dfc4545eea0cf02ffd84c91c54821e98a5317b95d81b7d3503acd4b120d422bdc63c185c73c13887e9401c8fc539a6e958e1b50ce6f424e687e4
|
7
|
+
data.tar.gz: 67f261017b5109ce12a659b48f62305cd509d512053a474a8e0c69b9ac42898856b79ffcca88c15e0038ceb109e05f714347f20dcf88026e1ec25de58ec535cf
|
data/bin/cfn_converge
CHANGED
@@ -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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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.
|
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-
|
11
|
+
date: 2016-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|