stackup 1.0.0 → 1.0.1

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: 70cf1deee1c8dc53041f2d6ff6cb31fdc9dac4f7
4
- data.tar.gz: 54fad33244ba8fe2c0935a95efed3ca897feb65b
3
+ metadata.gz: cac6ceefeefc19f6eea4ed171ddf4d596c75c778
4
+ data.tar.gz: df26370ed8fbe55624757667df93914105c8f8ad
5
5
  SHA512:
6
- metadata.gz: 8c250dadcf6d56e74423b0c191bd21c52e2790a0c7f73c15f2c506c4213be26582033642b7dadc6979cf62f2e41653cfd31e66e48c442942eccb6352fd410553
7
- data.tar.gz: cbc82bd3c82c85795636cd0e1e2febc30bc9ee307427f9b7f5c6cb1d51e633e7eb43335878061c686a8380f949314ffc8bcca316f58718b53b1f9c08c5151f9a
6
+ metadata.gz: 5f87618bdf6e7cd1869d5aaf9893a5e69d7605bfac22039c0e4ebfddb0d0dadf1c03f496071d771cf7819e289364401f5360d52ec52974799424914493252fa4
7
+ data.tar.gz: e9202e049b65f39bec6a51f8365fd1590e53a81464049404cb0f7a90c8477a19346c21036903c03a5fb8d4d550bb425ffee41693524c9025c40e9cd60d232b1f
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.0.1 (2016-12-07)
2
+
3
+ * Fix handling of "!GetAtt" in CloudFormation YAML.
4
+ * Special-case "!GetAZs" without an argument.
5
+ * Add Stack#template_body.
6
+
1
7
  ## 1.0.0 (2016-10-07)
2
8
 
3
9
  * Add support for CloudFormation YAML extensions (e.g. `!Ref`).
data/lib/stackup/stack.rb CHANGED
@@ -4,6 +4,7 @@ require "multi_json"
4
4
  require "stackup/error_handling"
5
5
  require "stackup/parameters"
6
6
  require "stackup/stack_watcher"
7
+ require "stackup/yaml"
7
8
 
8
9
  module Stackup
9
10
 
@@ -99,7 +100,7 @@ module Stackup
99
100
  # @option options [Hash] :template
100
101
  # stack template, as Ruby data
101
102
  # @option options [String] :template_body
102
- # stack template, as JSON
103
+ # stack template, as JSON or YAML
103
104
  # @option options [String] :template_url
104
105
  # location of stack template
105
106
  # @option options [Integer] :timeout_in_minutes
@@ -139,8 +140,6 @@ module Stackup
139
140
 
140
141
  # Delete the stack.
141
142
  #
142
- # @param [String] template template JSON
143
- # @param [Array<Hash>] parameters template parameters
144
143
  # @return [Symbol] +:deleted+ if successful
145
144
  # @raise [Stackup::StackUpdateError] if operation fails
146
145
  #
@@ -184,16 +183,24 @@ module Stackup
184
183
  end
185
184
  end
186
185
 
186
+ # Get the current template body.
187
+ #
188
+ # @return [String] current stack template, as JSON or YAML
189
+ # @raise [Stackup::NoSuchStack] if the stack doesn't exist
190
+ #
191
+ def template_body
192
+ handling_validation_error do
193
+ cf_client.get_template(:stack_name => name).template_body
194
+ end
195
+ end
196
+
187
197
  # Get the current template.
188
198
  #
189
199
  # @return [Hash] current stack template, as Ruby data
190
200
  # @raise [Stackup::NoSuchStack] if the stack doesn't exist
191
201
  #
192
202
  def template
193
- handling_validation_error do
194
- template_json = cf_client.get_template(:stack_name => name).template_body
195
- MultiJson.load(template_json)
196
- end
203
+ Stackup::YAML.load(template_body)
197
204
  end
198
205
 
199
206
  # Get the current parameters.
@@ -1,5 +1,5 @@
1
1
  module Stackup
2
2
 
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
 
5
5
  end
data/lib/stackup/yaml.rb CHANGED
@@ -47,6 +47,10 @@ module Stackup
47
47
  case target.tag
48
48
  when "!Ref"
49
49
  { "Ref" => super }
50
+ when "!GetAtt"
51
+ { "Fn::GetAtt" => super.split(".") }
52
+ when "!GetAZs"
53
+ { "Fn::GetAZs" => (super || "") }
50
54
  when /^!(\w+)$/
51
55
  { "Fn::#{$1}" => super }
52
56
  else
@@ -10,7 +10,7 @@ describe Stackup::YAML do
10
10
  described_class.load(input)
11
11
  end
12
12
 
13
- context "with plain YAML" do
13
+ describe "plain YAML" do
14
14
 
15
15
  let(:input) do
16
16
  <<-YAML
@@ -29,7 +29,7 @@ describe Stackup::YAML do
29
29
 
30
30
  end
31
31
 
32
- context "with a !Ref" do
32
+ describe "!Ref" do
33
33
 
34
34
  let(:input) do
35
35
  <<-YAML
@@ -50,16 +50,16 @@ describe Stackup::YAML do
50
50
 
51
51
  end
52
52
 
53
- context "with a !Ref" do
53
+ describe "!GetAtt" do
54
54
 
55
55
  let(:input) do
56
56
  <<-YAML
57
57
  Outputs:
58
- Foo: !GetAtt ["Bar", "Baz"]
58
+ Foo: !GetAtt Bar.Baz
59
59
  YAML
60
60
  end
61
61
 
62
- it "expands to Ref" do
62
+ it "expands to Fn::GetAtt" do
63
63
  expect(data).to eql(
64
64
  "Outputs" => {
65
65
  "Foo" => {
@@ -74,6 +74,77 @@ describe Stackup::YAML do
74
74
 
75
75
  end
76
76
 
77
+ describe "!GetAtt" do
78
+
79
+ context "with an argument" do
80
+
81
+ let(:input) do
82
+ <<-YAML
83
+ Foo:
84
+ !GetAZs xy-foobar-6
85
+ YAML
86
+ end
87
+
88
+ it "expands to Fn::GetAtt" do
89
+ expect(data).to eql(
90
+ "Foo" => {
91
+ "Fn::GetAZs" => "xy-foobar-6"
92
+ }
93
+ )
94
+ end
95
+
96
+ end
97
+
98
+ context "without an argument" do
99
+
100
+ let(:input) do
101
+ <<-YAML
102
+ Foo:
103
+ !GetAZs
104
+ YAML
105
+ end
106
+
107
+ it "infers a blank argument" do
108
+ expect(data).to eql(
109
+ "Foo" => {
110
+ "Fn::GetAZs" => ""
111
+ }
112
+ )
113
+ end
114
+
115
+ end
116
+
117
+ end
118
+
119
+ describe "!Whatever" do
120
+
121
+ let(:input) do
122
+ <<-YAML
123
+ Stuff:
124
+ - !FindInMap [RegionMap, !Ref "AWS::Region", AMI]
125
+ - !If [CreateProdResources, c1.xlarge, m1.small]
126
+ - !Join [ ":", [ "a", "b", "c" ] ]
127
+ YAML
128
+ end
129
+
130
+ it "expands to Fn::Whatever" do
131
+ expect(data).to eql(
132
+ "Stuff" => [
133
+ {
134
+ "Fn::FindInMap" => ["RegionMap", {"Ref"=>"AWS::Region"}, "AMI"]
135
+ },
136
+ {
137
+ "Fn::If" => ["CreateProdResources", "c1.xlarge", "m1.small"]
138
+ },
139
+ {
140
+ "Fn::Join" => [":", ["a", "b", "c"]]
141
+ }
142
+ ]
143
+ )
144
+ end
145
+
146
+ end
147
+
77
148
  end
78
149
 
79
150
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-07 00:00:00.000000000 Z
12
+ date: 2016-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk-resources
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  requirements: []
133
133
  rubyforge_project:
134
- rubygems_version: 2.5.1
134
+ rubygems_version: 2.6.8
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Manage CloudFormation stacks