cloudformation-tool 0.3.0 → 0.4.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea4d03ffcb514c887abcec0c712afed72c743f76
|
4
|
+
data.tar.gz: 0b1a375be3b6e62989f15145b2c483ece932427d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46dba8a5f1b5754ed7e4a19022a88153cc370a556b17c260142c3f4e59d0cea847f682e555f764a549bfc2566538edc6c638f4a7cf964bac51f0b1060f6c506d
|
7
|
+
data.tar.gz: 376779ced42644adc13227d5532f450e4b9cf7c42b2a12bdd99d86eea565e43824cedda316bfdc0ec500b1ba3b57e37244cfc00e1d19248d78d42f067f36abce
|
@@ -17,6 +17,7 @@ module CloudFormationTool
|
|
17
17
|
@path = "#{@path}.yaml" if !File.exist? @path and File.exist? "#{@path}.yaml"
|
18
18
|
@basedir = File.dirname(@path)
|
19
19
|
@compiled = false
|
20
|
+
@params = {}
|
20
21
|
text = File.read(@path)
|
21
22
|
# remove comments because white space seen between comments can seriously psych Psych
|
22
23
|
text.gsub!(/^#.*\n/s,'')
|
@@ -41,7 +42,8 @@ module CloudFormationTool
|
|
41
42
|
@data = load_files(@data)
|
42
43
|
end
|
43
44
|
|
44
|
-
def to_yaml
|
45
|
+
def to_yaml(parameters = {})
|
46
|
+
@params = parameters
|
45
47
|
compile.to_yaml
|
46
48
|
end
|
47
49
|
|
@@ -122,6 +124,22 @@ module CloudFormationTool
|
|
122
124
|
end
|
123
125
|
end
|
124
126
|
|
127
|
+
def resolveVale(value)
|
128
|
+
case value
|
129
|
+
when Hash
|
130
|
+
if value['Ref']
|
131
|
+
@params[value['Ref']] || # parameters are set for this template - we can resolve
|
132
|
+
# no parameters, we are probably in a sub template, just return the ref and hope a parent template
|
133
|
+
# has what it takes to resolve the ref
|
134
|
+
value
|
135
|
+
else
|
136
|
+
raise CloudFormationTool::Errors::AppError, "Value #{value} is not a valid value or reference"
|
137
|
+
end
|
138
|
+
else
|
139
|
+
value;
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
125
143
|
def load_files(data)
|
126
144
|
case data
|
127
145
|
when Array
|
@@ -136,7 +154,7 @@ module CloudFormationTool
|
|
136
154
|
{ "Fn::Base64" => { "Fn::Sub" => CloudInit.new("#{@basedir}/#{val["File"]}").compile } }
|
137
155
|
elsif (key == "Code") and (val["URL"])
|
138
156
|
# Support Lambda Code from arbitrary URLs
|
139
|
-
LambdaCode.new(val["URL"]).to_cloudformation
|
157
|
+
LambdaCode.new(resolveVal(val["URL"])).to_cloudformation
|
140
158
|
else
|
141
159
|
load_files(val)
|
142
160
|
end
|
@@ -45,7 +45,7 @@ module CloudFormationTool
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def create(template, params = {})
|
48
|
-
tmpl = CloudFormation.parse(template).to_yaml
|
48
|
+
tmpl = CloudFormation.parse(template).to_yaml(params)
|
49
49
|
url = upload(make_filename('yaml'), tmpl)
|
50
50
|
return update(url, template, params) if exist?
|
51
51
|
log "Creating stack '#{name}' from '#{template}' params #{params.inspect}"
|