214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
|
# File 'lib/cfhighlander.dsl.subcomponent.rb', line 214
def self.resolveValue(component, sub_component, param, available_outputs)
puts("INFO Resolving parameter #{component.name} -> #{sub_component.name}.#{param.name}: ")
if not param.provided_value.nil?
component_name = param.provided_value.split('.')[0]
output_name = param.provided_value.split('.')[1]
source_component = component.subcomponents.find {|c| c.name == component_name}
if source_component.nil?
source_component = component.subcomponents.find {|c| c.component_loaded.template.template_name == component_name}
end
return CfnDsl::Fn.new('GetAtt', [
source_component.name,
"Outputs.#{output_name}"
]).to_json
end
if sub_component.param_values.key?(param.name)
puts " parameter value provided "
param_value = sub_component.param_values[param.name]
if param_value.is_a? String and param_value.include? '.'
source_component_name = param_value.split('.')[0]
source_output = param_value.split('.')[1]
source_component = component.subcomponents.find {|sc| sc.name == source_component_name}
if not source_component.nil?
if source_component_name == sub_component.name
STDERR.puts "WARNING: Parameter value on component #{source_component_name} references component itself: #{param_value}"
else
return CfnDsl::Fn.new('GetAtt', [
source_component_name,
"Outputs.#{source_output}"
]).to_json
end
else
return Cfhighlander::Helper.parameter_cfndsl_value(param_value)
end
else
return Cfhighlander::Helper.parameter_cfndsl_value(sub_component.param_values[param.name])
end
end
if param.class == Cfhighlander::Dsl::MappingParam
puts " mapping parameter"
mapping_param_value = self.resolveMappingParamValue(component, sub_component, param)
return mapping_param_value unless mapping_param_value.nil?
end
if available_outputs.key? param.name
component_name = available_outputs[param.name].component.name
puts " resolved as output of #{component_name}"
return CfnDsl::Fn.new('GetAtt', [
component_name,
"Outputs.#{param.name}"
]).to_json
end
propagated_param = param.clone
propagated_param.name = "#{sub_component.cfn_name}#{param.name}" unless param.is_global
component.parameters.addParam propagated_param
puts " no autowiring candidates, propagate parameter to parent"
if param.type == 'CommaDelimitedList'
return CfnDsl::Fn.new('Join', [',',
CfnDsl::RefDefinition.new(propagated_param.name)
]).to_json
end
return CfnDsl::RefDefinition.new(propagated_param.name).to_json
end
|