rake-cloudformation 2 → 3

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.
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- gem 'aws-sdk'
2
+ gemspec
@@ -1,5 +1,5 @@
1
1
  # ex: syntax=ruby ts=2 sw=2 si et
2
- require 'aws/cloud_formation'
2
+ require 'aws-sdk'
3
3
 
4
4
  module Rake
5
5
  module CloudFormation
@@ -16,6 +16,7 @@ module Rake
16
16
  @region = 'us-east-1'
17
17
  @parameters = {}
18
18
  @capabilities = []
19
+ @notification_arns = []
19
20
  end
20
21
 
21
22
  def self.define_task(args, &block)
@@ -28,46 +29,57 @@ module Rake
28
29
  end
29
30
 
30
31
  attr_accessor :template, :region
31
- attr_reader :parameters, :capabilities
32
+ attr_reader :parameters, :capabilities, :notification_arns
32
33
 
33
34
  def prepare
34
35
  prerequisites << file(@template)
35
36
  end
36
37
 
37
38
  def needed?
38
- !cf(region).stacks[name].exists? or cf(region).stacks[name].status != 'CREATE_COMPLETE'
39
+ begin
40
+ cf(region).describe_stacks({stack_name: name}).stacks.first.stack_status != 'CREATE_COMPLETE'
41
+ rescue
42
+ true
43
+ end
39
44
  end
40
45
 
41
46
  def execute(*args)
42
47
  super
43
- options = {}
48
+ options = {
49
+ stack_name: name,
50
+ template_body: IO.read(template),
51
+ }
44
52
  unless parameters.empty?
45
- options[:parameters] = parameters.inject({}) do |hash, (key, value)|
53
+ options[:parameters] = parameters.inject([]) do |params, (key, value)|
54
+ param = {
55
+ :parameter_key => key
56
+ }
46
57
  if value.is_a?(String)
47
- hash[key] = value
58
+ param[:parameter_value] = value
48
59
  elsif value.is_a?(Proc)
49
- hash[key] = value.call
60
+ param[:parameter_value] = value.call
50
61
  else
51
62
  raise "Parameter value of unknown type: key=#{key.inspect} value=#{value.inspect}"
52
63
  end
53
- hash
64
+ params << param
65
+ params
54
66
  end
55
67
  end
56
- options[:capabilities] = capabilities unless capabilities.empty?
68
+ options[:capabilities] = capabilities.to_a unless capabilities.empty?
69
+ options[:notification_arns] = notification_arns unless notification_arns.empty?
57
70
  puts "Creating CloudFormation stack: #{name}"
58
- cf(region).stacks.create(name, IO.read(template), options)
59
- while cf(region).stacks[name].status === 'CREATE_IN_PROGRESS'
71
+ cf(region).create_stack(options)
72
+ while cf(region).describe_stacks({stack_name: name}).stacks.first.stack_status === 'CREATE_IN_PROGRESS'
60
73
  sleep 20
61
74
  end
62
- unless cf(region).stacks[name].status === 'CREATE_COMPLETE'
75
+ unless cf(region).describe_stacks({stack_name: name}).stacks.first.stack_status === 'CREATE_COMPLETE'
63
76
  raise "Stack creation failed"
64
77
  end
65
78
  end
66
79
  end
67
80
 
68
81
  def cf(region)
69
- AWS.config(:region => region)
70
- AWS::CloudFormation.new
82
+ Aws::CloudFormation::Client.new(region: region)
71
83
  end
72
84
  end
73
85
  end
@@ -77,7 +89,8 @@ def cfn_stack(args, &block)
77
89
  end
78
90
 
79
91
  def cfn_get_stack_output(stack_name, region, output_key)
80
- Rake::CloudFormation::Service.cf(region).stacks[stack_name].outputs.detect { |o| o.key === output_key }.value
92
+ Rake::CloudFormation::Service.cf(region).describe_stacks({stack_name: stack_name}).stacks.first.outputs
93
+ .detect { |o| o.output_key === output_key }.output_value
81
94
  end
82
95
 
83
96
  def cfn_stack_output(*args)
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.files = `git ls-files`.split($\)
11
11
  gem.name = 'rake-cloudformation'
12
12
  gem.require_paths = [ 'lib' ]
13
- gem.version = '2'
13
+ gem.version = '3'
14
14
 
15
- gem.add_runtime_dependency 'aws-sdk', '~> 1.59'
15
+ gem.add_runtime_dependency 'aws-sdk', '~> 2'
16
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-cloudformation
3
3
  version: !ruby/object:Gem::Version
4
- version: '2'
4
+ version: '3'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-07 00:00:00.000000000 Z
12
+ date: 2015-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '1.59'
21
+ version: '2'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '1.59'
29
+ version: '2'
30
30
  description: Library functions for defining tasks to start AWS CloudFormation stacks
31
31
  using rake
32
32
  email: inkblot@movealong.org