Class: CfnDsl::CloudFormationTemplate
- Defined in:
- lib/cfndsl.rb
Constant Summary collapse
- @@globalRefs =
{ "AWS::Region" => 1 }
Instance Method Summary collapse
- #checkRefs ⇒ Object
- #generateOutput ⇒ Object
-
#initialize ⇒ CloudFormationTemplate
constructor
A new instance of CloudFormationTemplate.
- #isValidRef(ref, origin = nil) ⇒ Object
Methods inherited from JSONable
#declare, #ref_children, #to_json
Methods included from Functions
#FnBase64, #FnFindInMap, #FnFormat, #FnGetAZs, #FnGetAtt, #FnJoin, #Ref
Methods included from RefCheck
Constructor Details
#initialize ⇒ CloudFormationTemplate
Returns a new instance of CloudFormationTemplate.
387 388 389 |
# File 'lib/cfndsl.rb', line 387 def initialize @AWSTemplateFormatVersion = "2010-09-09" end |
Instance Method Details
#checkRefs ⇒ Object
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 |
# File 'lib/cfndsl.rb', line 412 def checkRefs() invalids = [] @_ResourceRefs = {} if(@Resources) then @Resources.keys.each do |resource| @_ResourceRefs[resource.to_s] = @Resources[resource].references({}) end @_ResourceRefs.keys.each do |origin| @_ResourceRefs[origin].keys.each do |ref| invalids.push "Invalid Reference: Resource #{origin} refers to #{ref}" unless isValidRef(ref,origin) end end end outputRefs = {} if(@Outputs) then @Outputs.keys.each do |resource| outputRefs[resource.to_s] = @Outputs[resource].references({}) end outputRefs.keys.each do |origin| outputRefs[origin].keys.each do |ref| invalids.push "Invalid Reference: Output #{origin} refers to #{ref}" unless isValidRef(ref,nil) end end end return invalids.length>0 ? invalids : nil end |
#generateOutput ⇒ Object
391 392 393 |
# File 'lib/cfndsl.rb', line 391 def generateOutput() puts self.to_json # uncomment for pretty printing # {:space => ' ', :indent => ' ', :object_nl => "\n", :array_nl => "\n" } end |
#isValidRef(ref, origin = nil) ⇒ Object
397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/cfndsl.rb', line 397 def isValidRef( ref, origin=nil) ref = ref.to_s origin = origin.to_s if origin return true if @@globalRefs.has_key?( ref ) return true if @Parameters && @Parameters.has_key?( ref ) if( @Resources.has_key?( ref ) ) then return !origin || !@_ResourceRefs || !@_ResourceRefs[ref] || !@_ResourceRefs[ref].has_key?(origin) end return false end |