aws-sdk-utils 0.0.12 → 0.0.13

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: f0fe2c0d0382363a3af8c7e2d8a5e75ab80b8050
4
- data.tar.gz: a4fdd3f6541ae2fb7f7ec1b5b4cdd53340045c3f
3
+ metadata.gz: 0e8fbf062269b50c357e7d0d2c7b3217dc23e5d6
4
+ data.tar.gz: 2154657b6fc1aef662c5ca91067f8cd994b77ee9
5
5
  SHA512:
6
- metadata.gz: 4a19c708fde82eb7bdfc8df14cad8df097dfc6cda668739737294596cf50b81691e898805af0507a4217f33195670a053c72524075d9ed7951f245fe9e3aebe2
7
- data.tar.gz: 29c635f78077bf5ce25139376a8daeb5caf1c1e9b6315681204f8d2de1810286ba37d633a50aeb64692b3c593b562f43c6f70f7b712b9f935583ba3114ecdf21
6
+ metadata.gz: 19a8b56ebf31de6998b580a81b006945432e174aa074b7dd38464bf9c83fa4f517931d465f5ac6e8133856967536eba5c381dbe33e41aa8d41775a055af12461
7
+ data.tar.gz: 87ad63032d0262343c043622f98c12c6732970d2e68b9a0483c7341325ba8a19d8a5b94a284087ca2f474308c8e361b93ab5ff04de77eadbe6b56267f1a929f2
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ require 'trollop'
3
+ require 'cloudformation_converger'
4
+ require 'yaml'
5
+
6
+ opts = Trollop::options do
7
+ opt :path_to_stack, '', type: :string, required: true
8
+ opt :stack_name, '', type: :string, required: true
9
+ opt :path_to_yaml, '', type: :string, required: false
10
+ end
11
+
12
+ bindings = opts[:path_to_yaml].nil? ? nil : YAML.load_file(opts[:path_to_yaml])
13
+
14
+ begin
15
+ outputs = CloudFormationConverger.new.converge(stack_name: opts[:stack_name],
16
+ stack_path: opts[:path_to_stack],
17
+ bindings: bindings)
18
+
19
+ puts outputs.to_yaml
20
+ rescue Exception => e
21
+ puts e.message
22
+ exit 1
23
+ end
@@ -1,9 +1,16 @@
1
1
  require 'aws-sdk'
2
+ require 'yaml'
2
3
 
3
4
  class CloudFormationConverger
4
5
 
5
6
  def converge(stack_name:,
6
- stack_path:)
7
+ stack_path:,
8
+ bindings: nil)
9
+
10
+ parameters = []
11
+ unless bindings.nil?
12
+ parameters = convert_hash_to_parameters bindings
13
+ end
7
14
 
8
15
  cloudformation_client = Aws::CloudFormation::Client.new
9
16
  resource = Aws::CloudFormation::Resource.new(client: cloudformation_client)
@@ -11,7 +18,8 @@ class CloudFormationConverger
11
18
  stack = resource.stack(stack_name)
12
19
  begin
13
20
  stack.update(template_body: IO.read(stack_path),
14
- capabilities: %w(CAPABILITY_IAM))
21
+ capabilities: %w(CAPABILITY_IAM),
22
+ parameters: parameters)
15
23
  rescue Exception => error
16
24
  if error.to_s =~ /No updates are to be performed/
17
25
  puts 'no updates necessary'
@@ -23,14 +31,15 @@ class CloudFormationConverger
23
31
  else
24
32
  stack = resource.create_stack(stack_name: stack_name,
25
33
  template_body: IO.read(stack_path),
26
- capabilities: %w(CAPABILITY_IAM))
34
+ capabilities: %w(CAPABILITY_IAM),
35
+ parameters: parameters)
27
36
  end
28
37
 
29
38
  stack.wait_until(max_attempts:100, delay:15) do |stack|
30
39
  stack.stack_status =~ /COMPLETE/ or stack.stack_status =~ /FAILED/
31
40
  end
32
41
 
33
- if stack.stack_status =~ /FAILED/
42
+ if stack.stack_status =~ /FAILED/ or stack.stack_status =~ /ROLLBACK_COMPLETE/
34
43
  raise "#{stack_name} failed to converge: #{stack.stack_status}"
35
44
  end
36
45
 
@@ -39,4 +48,18 @@ class CloudFormationConverger
39
48
  hash
40
49
  end
41
50
  end
51
+
52
+ private
53
+
54
+ def convert_hash_to_parameters(hash)
55
+ parameters = []
56
+ hash.each do |k,v|
57
+ parameters << {
58
+ parameter_key: k,
59
+ parameter_value: v,
60
+ use_previous_value: false
61
+ }
62
+ end
63
+ parameters
64
+ end
42
65
  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.12
4
+ version: 0.0.13
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-06 00:00:00.000000000 Z
11
+ date: 2016-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -58,9 +58,11 @@ executables:
58
58
  - cfndsl_converge
59
59
  - yaml_get
60
60
  - cfndsl_chain_converge
61
+ - cfn_converge
61
62
  extensions: []
62
63
  extra_rdoc_files: []
63
64
  files:
65
+ - bin/cfn_converge
64
66
  - bin/cfndsl_chain_converge
65
67
  - bin/cfndsl_converge
66
68
  - bin/yaml_get