186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
# File 'lib/cloud_formation_tool/cloud_formation.rb', line 186
def load_files(data, restype = nil)
case data
when Array
data.collect { |data| load_files(data, restype) }
when Hash
restype = data['Type'] if restype.nil? and data.key?('Type')
data.inject({}) do |dict, (key, val)|
dict[key] = case restype
when 'AWS::AutoScaling::LaunchConfiguration', 'AWS::EC2::LaunchTemplate'
if (key == "UserData") and (val["File"])
CloudInit.new("#{@basedir}/#{val["File"]}").to_base64
elsif (key == "UserData") and (val["FileTemplate"])
{ "Fn::Base64" => { "Fn::Sub" => CloudInit.new("#{@basedir}/#{val["FileTemplate"]}").compile } }
else
load_files(val, restype)
end
when 'AWS::Lambda::Function'
if key == 'Code'
LambdaCode.new(val, self, data['Runtime']).to_cloudformation
else
load_files(val, restype)
end
when 'AWS::CloudFormation::Stack'
if key == 'Properties' and val.key?('Template')
NestedStack.new(val, self).to_cloudformation
else
load_files(val, restype)
end
else
load_files(val, restype)
end
dict
end
else
data
end
end
|