stackup 0.9.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -1
- data/README.md +6 -2
- data/bin/stackup +2 -2
- data/lib/stackup/version.rb +1 -1
- data/lib/stackup/yaml.rb +61 -0
- data/spec/stackup/yaml_spec.rb +79 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70cf1deee1c8dc53041f2d6ff6cb31fdc9dac4f7
|
4
|
+
data.tar.gz: 54fad33244ba8fe2c0935a95efed3ca897feb65b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c250dadcf6d56e74423b0c191bd21c52e2790a0c7f73c15f2c506c4213be26582033642b7dadc6979cf62f2e41653cfd31e66e48c442942eccb6352fd410553
|
7
|
+
data.tar.gz: cbc82bd3c82c85795636cd0e1e2febc30bc9ee307427f9b7f5c6cb1d51e633e7eb43335878061c686a8380f949314ffc8bcca316f58718b53b1f9c08c5151f9a
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -37,8 +37,6 @@ Called with `--list`, it will list stacks:
|
|
37
37
|
foo-bar-test
|
38
38
|
zzz-production
|
39
39
|
|
40
|
-
The command-line support inputs (template and parameters) in either JSON or YAML format.
|
41
|
-
|
42
40
|
### Stack create/update
|
43
41
|
|
44
42
|
Use sub-command "up" to create or update a stack, as appropriate:
|
@@ -102,6 +100,12 @@ Parameters and tags may be specified via files, or as a Hash, e.g.
|
|
102
100
|
t.tags = { "environment" => "production" }
|
103
101
|
end
|
104
102
|
|
103
|
+
## YAML support
|
104
|
+
|
105
|
+
Stackup supports input files (template, parameters, tags) in either JSON or YAML format.
|
106
|
+
|
107
|
+
It also supports the [abbreviated YAML syntax for Cloudformation functions](https://aws.amazon.com/blogs/aws/aws-cloudformation-update-yaml-cross-stack-references-simplified-substitution/), though unlike the [AWS CLI](https://aws.amazon.com/cli/), Stackup normalises YAML input to JSON before invoking CloudFormation APIs.
|
108
|
+
|
105
109
|
## Docker image
|
106
110
|
|
107
111
|
Stackup is also published as a Docker image. Basic usage is:
|
data/bin/stackup
CHANGED
@@ -9,7 +9,7 @@ require "securerandom"
|
|
9
9
|
require "stackup"
|
10
10
|
require "stackup/differ"
|
11
11
|
require "stackup/version"
|
12
|
-
require "yaml"
|
12
|
+
require "stackup/yaml"
|
13
13
|
|
14
14
|
$stdout.sync = true
|
15
15
|
$stderr.sync = true
|
@@ -127,7 +127,7 @@ Clamp do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def load_data(file)
|
130
|
-
YAML.load_file(file)
|
130
|
+
Stackup::YAML.load_file(file)
|
131
131
|
rescue Errno::ENOENT
|
132
132
|
signal_error "no such file: #{file.inspect}"
|
133
133
|
end
|
data/lib/stackup/version.rb
CHANGED
data/lib/stackup/yaml.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module Stackup
|
4
|
+
|
5
|
+
# Modified YAML parsing, to support CloudFormation YAML shortcuts
|
6
|
+
#
|
7
|
+
module YAML
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
# Dump Ruby object +o+ to a YAML string.
|
12
|
+
#
|
13
|
+
def dump(*args)
|
14
|
+
::YAML.dump(*args)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Load YAML stream/string into a Ruby data structure.
|
18
|
+
#
|
19
|
+
# Supports CloudFormation extensions:
|
20
|
+
#
|
21
|
+
# `!Ref blah` as a shortcut for `{ "Ref" => blah }`
|
22
|
+
# `!Foo blah` as a shortcut for `{ "Fn::Foo" => blah }`
|
23
|
+
#
|
24
|
+
def load(yaml, filename = nil)
|
25
|
+
tree = ::YAML.parse(yaml, filename)
|
26
|
+
return tree unless tree
|
27
|
+
CloudFormationToRuby.create.accept(tree)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Load YAML file into a Ruby data structure.
|
31
|
+
#
|
32
|
+
# Supports CloudFormation extensions as per `load`.
|
33
|
+
#
|
34
|
+
def load_file(filename)
|
35
|
+
File.open(filename, 'r:bom|utf-8') do |f|
|
36
|
+
load(f, filename)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
# Custom Psych node visitor, with CloudFormation extensions.
|
43
|
+
#
|
44
|
+
class CloudFormationToRuby < Psych::Visitors::ToRuby
|
45
|
+
|
46
|
+
def accept(target)
|
47
|
+
case target.tag
|
48
|
+
when "!Ref"
|
49
|
+
{ "Ref" => super }
|
50
|
+
when /^!(\w+)$/
|
51
|
+
{ "Fn::#{$1}" => super }
|
52
|
+
else
|
53
|
+
super
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "stackup/yaml"
|
4
|
+
|
5
|
+
describe Stackup::YAML do
|
6
|
+
|
7
|
+
describe ".load" do
|
8
|
+
|
9
|
+
let(:data) do
|
10
|
+
described_class.load(input)
|
11
|
+
end
|
12
|
+
|
13
|
+
context "with plain YAML" do
|
14
|
+
|
15
|
+
let(:input) do
|
16
|
+
<<-YAML
|
17
|
+
Outputs:
|
18
|
+
Foo: "bar"
|
19
|
+
YAML
|
20
|
+
end
|
21
|
+
|
22
|
+
it "loads as normal" do
|
23
|
+
expect(data).to eql(
|
24
|
+
"Outputs" => {
|
25
|
+
"Foo" => "bar"
|
26
|
+
}
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
context "with a !Ref" do
|
33
|
+
|
34
|
+
let(:input) do
|
35
|
+
<<-YAML
|
36
|
+
Outputs:
|
37
|
+
Foo: !Ref "Bar"
|
38
|
+
YAML
|
39
|
+
end
|
40
|
+
|
41
|
+
it "expands to Ref" do
|
42
|
+
expect(data).to eql(
|
43
|
+
"Outputs" => {
|
44
|
+
"Foo" => {
|
45
|
+
"Ref" => "Bar"
|
46
|
+
}
|
47
|
+
}
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
context "with a !Ref" do
|
54
|
+
|
55
|
+
let(:input) do
|
56
|
+
<<-YAML
|
57
|
+
Outputs:
|
58
|
+
Foo: !GetAtt ["Bar", "Baz"]
|
59
|
+
YAML
|
60
|
+
end
|
61
|
+
|
62
|
+
it "expands to Ref" do
|
63
|
+
expect(data).to eql(
|
64
|
+
"Outputs" => {
|
65
|
+
"Foo" => {
|
66
|
+
"Fn::GetAtt" => [
|
67
|
+
"Bar",
|
68
|
+
"Baz"
|
69
|
+
]
|
70
|
+
}
|
71
|
+
}
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
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: 0.
|
4
|
+
version: 1.0.0
|
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-
|
12
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aws-sdk-resources
|
@@ -104,11 +104,13 @@ files:
|
|
104
104
|
- lib/stackup/stack_watcher.rb
|
105
105
|
- lib/stackup/utils.rb
|
106
106
|
- lib/stackup/version.rb
|
107
|
+
- lib/stackup/yaml.rb
|
107
108
|
- spec/spec_helper.rb
|
108
109
|
- spec/stackup/parameters_spec.rb
|
109
110
|
- spec/stackup/stack_spec.rb
|
110
111
|
- spec/stackup/stack_watcher_spec.rb
|
111
112
|
- spec/stackup/utils_spec.rb
|
113
|
+
- spec/stackup/yaml_spec.rb
|
112
114
|
homepage: https://github.com/realestate-com-au/stackup
|
113
115
|
licenses:
|
114
116
|
- MIT
|
@@ -129,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
131
|
version: '0'
|
130
132
|
requirements: []
|
131
133
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
134
|
+
rubygems_version: 2.5.1
|
133
135
|
signing_key:
|
134
136
|
specification_version: 4
|
135
137
|
summary: Manage CloudFormation stacks
|
@@ -139,3 +141,4 @@ test_files:
|
|
139
141
|
- spec/stackup/stack_spec.rb
|
140
142
|
- spec/stackup/stack_watcher_spec.rb
|
141
143
|
- spec/stackup/utils_spec.rb
|
144
|
+
- spec/stackup/yaml_spec.rb
|