cloudformation-tool 0.4.1 → 0.4.2
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 +4 -4
 - data/lib/cloud_formation_tool/cloud_formation.rb +18 -5
 - data/lib/cloud_formation_tool/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e7b9610569b0d65c7af93fc51430e33d2020f8cc
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9d0199f6d1ed1193418eb7a912c313abadd10e5e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d1e0e9be5c9ece04814e98fb42831508cc1310adbae7c615e2b4fba6b604b0fdf0b5132a094a0f8bd8a327c9c8af53666fd6d67cdc189589ac156923b7756169
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c9aced3e58604de4d2c33285ccb9ffcb99eba55ec1b77f0320770550ea99b78035303279777c1d9a56782a33c53ee253a3dddc464ecb31ff843ed491d0b3369f
         
     | 
| 
         @@ -17,7 +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 
     | 
    
         
            +
                  @params = nil
         
     | 
| 
       21 
21 
     | 
    
         
             
                  text = File.read(@path)
         
     | 
| 
       22 
22 
     | 
    
         
             
                  # remove comments because white space seen between comments can seriously psych Psych
         
     | 
| 
       23 
23 
     | 
    
         
             
                  text.gsub!(/^#.*\n/s,'')
         
     | 
| 
         @@ -128,10 +128,17 @@ module CloudFormationTool 
     | 
|
| 
       128 
128 
     | 
    
         
             
                  case value
         
     | 
| 
       129 
129 
     | 
    
         
             
                  when Hash
         
     | 
| 
       130 
130 
     | 
    
         
             
                    if value['Ref']
         
     | 
| 
       131 
     | 
    
         
            -
                      @params 
     | 
| 
       132 
     | 
    
         
            -
                        # no parameters, we are probably in a sub template, just return the ref and hope 
     | 
| 
       133 
     | 
    
         
            -
                        # has what it takes to resolve the ref
         
     | 
| 
      
 131 
     | 
    
         
            +
                      if @params.nil?
         
     | 
| 
      
 132 
     | 
    
         
            +
                        # no parameters, we are probably in a sub template, just return the ref and hope
         
     | 
| 
      
 133 
     | 
    
         
            +
                        # a parent template has what it takes to resolve the ref
         
     | 
| 
       134 
134 
     | 
    
         
             
                        value
         
     | 
| 
      
 135 
     | 
    
         
            +
                      else # parameters are set for this template - we can try to resolve
         
     | 
| 
      
 136 
     | 
    
         
            +
                        res = @params[value['Ref']] || (@data['Parameters']||{})[value['Ref']] 
         
     | 
| 
      
 137 
     | 
    
         
            +
                        if res.nil?
         
     | 
| 
      
 138 
     | 
    
         
            +
                          raise CloudFormationTool::Errors::AppError, "Reference #{value['Ref']} can't be resolved"
         
     | 
| 
      
 139 
     | 
    
         
            +
                        end
         
     | 
| 
      
 140 
     | 
    
         
            +
                        res
         
     | 
| 
      
 141 
     | 
    
         
            +
                      end
         
     | 
| 
       135 
142 
     | 
    
         
             
                    else
         
     | 
| 
       136 
143 
     | 
    
         
             
                      raise CloudFormationTool::Errors::AppError, "Value #{value} is not a valid value or reference"
         
     | 
| 
       137 
144 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -154,7 +161,13 @@ module CloudFormationTool 
     | 
|
| 
       154 
161 
     | 
    
         
             
                        { "Fn::Base64" => { "Fn::Sub" => CloudInit.new("#{@basedir}/#{val["File"]}").compile } }
         
     | 
| 
       155 
162 
     | 
    
         
             
                      elsif (key == "Code") and (val["URL"])
         
     | 
| 
       156 
163 
     | 
    
         
             
                        # Support Lambda Code from arbitrary URLs
         
     | 
| 
       157 
     | 
    
         
            -
                         
     | 
| 
      
 164 
     | 
    
         
            +
                        url = resolveVal(val["URL"])
         
     | 
| 
      
 165 
     | 
    
         
            +
                        if url.is_a? String # resolving works
         
     | 
| 
      
 166 
     | 
    
         
            +
                          LambdaCode.new(url).to_cloudformation
         
     | 
| 
      
 167 
     | 
    
         
            +
                        else # resolving didn't work - we probably don't have parameters
         
     | 
| 
      
 168 
     | 
    
         
            +
                          # push it upstream and hope a parent template can resolve it
         
     | 
| 
      
 169 
     | 
    
         
            +
                          val
         
     | 
| 
      
 170 
     | 
    
         
            +
                        end
         
     | 
| 
       158 
171 
     | 
    
         
             
                      else 
         
     | 
| 
       159 
172 
     | 
    
         
             
                        load_files(val)
         
     | 
| 
       160 
173 
     | 
    
         
             
                      end
         
     |