cfndsl 0.0.16 → 0.1.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 +7 -0
- data/lib/cfndsl.rb +5 -5
- data/lib/cfndsl/CloudFormationTemplate.rb +20 -18
- data/lib/cfndsl/Conditions.rb +19 -0
- data/lib/cfndsl/Errors.rb +6 -8
- data/lib/cfndsl/JSONable.rb +67 -25
- data/lib/cfndsl/Outputs.rb +3 -3
- data/lib/cfndsl/Plurals.rb +4 -1
- data/lib/cfndsl/Resources.rb +5 -4
- data/lib/cfndsl/UpdatePolicy.rb +29 -0
- data/lib/cfndsl/aws_types.yaml +37 -12
- metadata +38 -10
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 7b265f1255b48223c012215b895145a7d520249c
         | 
| 4 | 
            +
              data.tar.gz: ca61f61cda439daec8d124369f5d5f28f9b31c80
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: f0df157ea4421e9b3d8426f65d7f30fa57ae27ebf372bcda3699507001b36429b4cfb752096ce95c0add85055f357338478a230a5028ecdcadd4361c5717432e
         | 
| 7 | 
            +
              data.tar.gz: 48e9633475ed557c62380ff07c0277fb904ad3f63743daaeaeaf2e333b47335e2070e72c472ed782a692a2fd78cc00b313704bb59ed1626f78e2576dc705c7d7
         | 
    
        data/lib/cfndsl.rb
    CHANGED
    
    | @@ -6,25 +6,25 @@ require 'cfndsl/RefCheck' | |
| 6 6 | 
             
            require 'cfndsl/JSONable'
         | 
| 7 7 | 
             
            require 'cfndsl/Types'
         | 
| 8 8 | 
             
            require 'cfndsl/Properties'
         | 
| 9 | 
            +
            require 'cfndsl/UpdatePolicy'
         | 
| 10 | 
            +
            require 'cfndsl/Conditions'
         | 
| 9 11 | 
             
            require 'cfndsl/Mappings'
         | 
| 10 12 | 
             
            require 'cfndsl/Resources'
         | 
| 11 13 | 
             
            require 'cfndsl/Metadata'
         | 
| 12 14 | 
             
            require 'cfndsl/Parameters'
         | 
| 13 15 | 
             
            require 'cfndsl/Outputs'
         | 
| 14 | 
            -
            require 'cfndsl/CloudFormationTemplate' | 
| 16 | 
            +
            require 'cfndsl/CloudFormationTemplate'
         | 
| 15 17 |  | 
| 16 18 | 
             
            def CloudFormation(&block)
         | 
| 17 19 | 
             
              x = CfnDsl::CloudFormationTemplate.new
         | 
| 18 20 | 
             
              x.declare(&block)
         | 
| 19 21 | 
             
              invalid_references = x.checkRefs()
         | 
| 20 22 | 
             
              if( invalid_references ) then
         | 
| 21 | 
            -
                 | 
| 22 | 
            -
                exit(-1)
         | 
| 23 | 
            +
                abort invalid_references.join("\n")
         | 
| 23 24 | 
             
              elsif( CfnDsl::Errors.errors? ) then
         | 
| 24 | 
            -
                CfnDsl::Errors. | 
| 25 | 
            +
                abort CfnDsl::Errors.errors.join("\n")
         | 
| 25 26 | 
             
              else
         | 
| 26 27 | 
             
                x.generateOutput
         | 
| 27 28 | 
             
              end
         | 
| 28 29 | 
             
            end
         | 
| 29 30 |  | 
| 30 | 
            -
             | 
| @@ -1,26 +1,28 @@ | |
| 1 1 | 
             
            require 'cfndsl/JSONable'
         | 
| 2 2 | 
             
            require 'cfndsl/names'
         | 
| 3 3 |  | 
| 4 | 
            -
            module CfnDsl | 
| 5 | 
            -
              class CloudFormationTemplate < JSONable | 
| 4 | 
            +
            module CfnDsl
         | 
| 5 | 
            +
              class CloudFormationTemplate < JSONable
         | 
| 6 6 | 
             
                ##
         | 
| 7 7 | 
             
                # Handles the overall template object
         | 
| 8 8 | 
             
                dsl_attr_setter :AWSTemplateFormatVersion, :Description
         | 
| 9 | 
            -
                dsl_content_object :Parameter, :Output, :Resource, :Mapping
         | 
| 10 | 
            -
             | 
| 9 | 
            +
                dsl_content_object :Condition, :Parameter, :Output, :Resource, :Mapping
         | 
| 10 | 
            +
             | 
| 11 11 | 
             
                def initialize
         | 
| 12 12 | 
             
                  @AWSTemplateFormatVersion = "2010-09-09"
         | 
| 13 13 | 
             
                end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                def generateOutput() | 
| 14 | 
            +
             | 
| 15 | 
            +
                def generateOutput()
         | 
| 16 16 | 
             
                  puts self.to_json  # uncomment for pretty printing # {:space => ' ', :indent => '  ', :object_nl => "\n", :array_nl => "\n" }
         | 
| 17 17 | 
             
                end
         | 
| 18 18 |  | 
| 19 | 
            -
                @@globalRefs = { | 
| 20 | 
            -
                   "AWS::NotificationARNs" => 1, | 
| 19 | 
            +
                @@globalRefs = {
         | 
| 20 | 
            +
                   "AWS::NotificationARNs" => 1,
         | 
| 21 21 | 
             
                   "AWS::Region" => 1,
         | 
| 22 22 | 
             
                   "AWS::StackId" => 1,
         | 
| 23 | 
            -
                   "AWS::StackName" => 1
         | 
| 23 | 
            +
                   "AWS::StackName" => 1,
         | 
| 24 | 
            +
                   "AWS::AccountId" => 1,
         | 
| 25 | 
            +
                   "AWS::NoValue" => 1
         | 
| 24 26 | 
             
                }
         | 
| 25 27 |  | 
| 26 28 | 
             
                def isValidRef( ref, origin=nil)
         | 
| @@ -30,15 +32,15 @@ module CfnDsl | |
| 30 32 | 
             
                  return true if @@globalRefs.has_key?( ref )
         | 
| 31 33 |  | 
| 32 34 | 
             
                  return true if @Parameters && @Parameters.has_key?( ref )
         | 
| 33 | 
            -
             | 
| 35 | 
            +
             | 
| 34 36 | 
             
                  if( @Resources.has_key?( ref ) ) then
         | 
| 35 | 
            -
                      return !origin || !@_ResourceRefs || !@_ResourceRefs[ref] || !@_ResourceRefs[ref].has_key?(origin) | 
| 37 | 
            +
                      return !origin || !@_ResourceRefs || !@_ResourceRefs[ref] || !@_ResourceRefs[ref].has_key?(origin)
         | 
| 36 38 | 
             
                  end
         | 
| 37 39 |  | 
| 38 40 | 
             
                  return false
         | 
| 39 41 | 
             
                end
         | 
| 40 42 |  | 
| 41 | 
            -
                def checkRefs() | 
| 43 | 
            +
                def checkRefs()
         | 
| 42 44 | 
             
                  invalids = []
         | 
| 43 45 | 
             
                  @_ResourceRefs = {}
         | 
| 44 46 | 
             
                  if(@Resources)  then
         | 
| @@ -62,10 +64,10 @@ module CfnDsl | |
| 62 64 | 
             
                      end
         | 
| 63 65 | 
             
                    end
         | 
| 64 66 | 
             
                  end
         | 
| 65 | 
            -
                  return invalids.length>0 ? invalids : nil | 
| 67 | 
            +
                  return invalids.length>0 ? invalids : nil
         | 
| 66 68 | 
             
                end
         | 
| 67 69 |  | 
| 68 | 
            -
             | 
| 70 | 
            +
             | 
| 69 71 | 
             
                names = {}
         | 
| 70 72 | 
             
                nametypes = {}
         | 
| 71 73 | 
             
                CfnDsl::Types::AWS_Types["Resources"].each_pair do |name, type|
         | 
| @@ -77,11 +79,11 @@ module CfnDsl | |
| 77 79 | 
             
                    if( ptype.instance_of? String )
         | 
| 78 80 | 
             
                      create_klass = CfnDsl::Types.const_get( ptype );
         | 
| 79 81 |  | 
| 80 | 
            -
                      klass.class_eval do | 
| 82 | 
            +
                      klass.class_eval do
         | 
| 81 83 | 
             
                        CfnDsl::methodNames(pname) do |method|
         | 
| 82 84 | 
             
                          define_method(method) do |*values, &block|
         | 
| 83 85 | 
             
                            if( values.length <1 ) then
         | 
| 84 | 
            -
                              values.push create_klass.new | 
| 86 | 
            +
                              values.push create_klass.new
         | 
| 85 87 | 
             
                            end
         | 
| 86 88 | 
             
                            @Properties ||= {}
         | 
| 87 89 | 
             
                            @Properties[pname] ||= CfnDsl::PropertyDefinition.new( *values )
         | 
| @@ -124,7 +126,7 @@ module CfnDsl | |
| 124 126 |  | 
| 125 127 | 
             
                  end
         | 
| 126 128 | 
             
                  parts = name.split "::"
         | 
| 127 | 
            -
                  while( parts.length > 0) | 
| 129 | 
            +
                  while( parts.length > 0)
         | 
| 128 130 | 
             
                    abreve_name = parts.join "_"
         | 
| 129 131 | 
             
                    if( names.has_key? abreve_name ) then
         | 
| 130 132 | 
             
                      # this only happens if there is an ambiguity
         | 
| @@ -138,7 +140,7 @@ module CfnDsl | |
| 138 140 |  | 
| 139 141 |  | 
| 140 142 | 
             
                end
         | 
| 141 | 
            -
             | 
| 143 | 
            +
             | 
| 142 144 | 
             
                #Define property setter methods for each of the unambiguous type names
         | 
| 143 145 | 
             
                names.each_pair do |typename,type|
         | 
| 144 146 | 
             
                  if(type) then
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            require 'cfndsl/JSONable'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module CfnDsl
         | 
| 4 | 
            +
              class ConditionDefinition < JSONable
         | 
| 5 | 
            +
                #
         | 
| 6 | 
            +
                # Handles condition objects
         | 
| 7 | 
            +
                #
         | 
| 8 | 
            +
                # Usage:
         | 
| 9 | 
            +
                #     Condition :ConditionName, FnEqual(Ref(:ParameterName), 'helloworld')
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                def initialize(value)
         | 
| 12 | 
            +
                  @value = value
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                def to_json(*a)
         | 
| 16 | 
            +
                  @value.to_json(*a)
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
    
        data/lib/cfndsl/Errors.rb
    CHANGED
    
    | @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            module CfnDsl
         | 
| 2 2 | 
             
              module Errors
         | 
| 3 3 | 
             
                @@errors = []
         | 
| 4 | 
            -
             | 
| 5 | 
            -
                def self.error( err, idx=nil ) | 
| 4 | 
            +
             | 
| 5 | 
            +
                def self.error( err, idx=nil )
         | 
| 6 6 | 
             
                  if(idx.nil?) then
         | 
| 7 7 | 
             
                    @@errors.push ( err + "\n" + caller.join("\n") + "\n" )
         | 
| 8 8 | 
             
                  else
         | 
| @@ -11,19 +11,17 @@ module CfnDsl | |
| 11 11 | 
             
                    else
         | 
| 12 12 | 
             
                      err_loc = caller[idx]
         | 
| 13 13 | 
             
                    end
         | 
| 14 | 
            -
             | 
| 14 | 
            +
             | 
| 15 15 | 
             
                    @@errors.push ( err_loc + " " + err + "\n" )
         | 
| 16 16 | 
             
                  end
         | 
| 17 17 | 
             
                end
         | 
| 18 | 
            -
             | 
| 18 | 
            +
             | 
| 19 19 | 
             
                def self.clear()
         | 
| 20 20 | 
             
                  @@errors = []
         | 
| 21 21 | 
             
                end
         | 
| 22 22 |  | 
| 23 | 
            -
                def self. | 
| 24 | 
            -
                  @@errors | 
| 25 | 
            -
                    puts err
         | 
| 26 | 
            -
                  end
         | 
| 23 | 
            +
                def self.errors()
         | 
| 24 | 
            +
                  @@errors
         | 
| 27 25 | 
             
                end
         | 
| 28 26 |  | 
| 29 27 | 
             
                def self.errors?()
         | 
    
        data/lib/cfndsl/JSONable.rb
    CHANGED
    
    | @@ -6,64 +6,106 @@ module CfnDsl | |
| 6 6 | 
             
                ##
         | 
| 7 7 | 
             
                # These functions are available anywhere inside
         | 
| 8 8 | 
             
                # a block for a JSONable object.
         | 
| 9 | 
            -
                def Ref(value) | 
| 9 | 
            +
                def Ref(value)
         | 
| 10 10 | 
             
                  ##
         | 
| 11 11 | 
             
                  # Equivalent to the CloudFormation template built in function Ref
         | 
| 12 12 | 
             
                  RefDefinition.new(value)
         | 
| 13 13 | 
             
                end
         | 
| 14 | 
            -
             | 
| 14 | 
            +
             | 
| 15 15 | 
             
                def FnBase64( value )
         | 
| 16 16 | 
             
                  ##
         | 
| 17 17 | 
             
                  # Equivalent to the CloudFormation template built in function Fn::Base64
         | 
| 18 18 | 
             
                  Fn.new("Base64", value);
         | 
| 19 19 | 
             
                end
         | 
| 20 | 
            -
             | 
| 20 | 
            +
             | 
| 21 21 | 
             
                def FnFindInMap( map, key, value)
         | 
| 22 22 | 
             
                  ##
         | 
| 23 23 | 
             
                  # Equivalent to the CloudFormation template built in function Fn::FindInMap
         | 
| 24 24 | 
             
                  Fn.new("FindInMap", [map,key,value] )
         | 
| 25 | 
            -
                end | 
| 26 | 
            -
             | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 27 | 
             
                def FnGetAtt(logicalResource, attribute)
         | 
| 28 28 | 
             
                  ##
         | 
| 29 29 | 
             
                  # Equivalent to the CloudFormation template built in function Fn::GetAtt
         | 
| 30 | 
            -
                  Fn.new( "GetAtt", [logicalResource, attribute] | 
| 30 | 
            +
                  Fn.new( "GetAtt", [logicalResource, attribute] )
         | 
| 31 31 | 
             
                end
         | 
| 32 | 
            -
             | 
| 32 | 
            +
             | 
| 33 33 | 
             
                def FnGetAZs(region)
         | 
| 34 34 | 
             
                  ##
         | 
| 35 35 | 
             
                  # Equivalent to the CloudFormation template built in function Fn::GetAZs
         | 
| 36 36 | 
             
                  Fn.new("GetAZs", region)
         | 
| 37 37 | 
             
                end
         | 
| 38 | 
            -
             | 
| 38 | 
            +
             | 
| 39 39 | 
             
                def FnJoin(string, array)
         | 
| 40 40 | 
             
                  ##
         | 
| 41 41 | 
             
                  # Equivalent to the CloudFormation template built in function Fn::Join
         | 
| 42 42 | 
             
                  Fn.new("Join", [ string, array] )
         | 
| 43 43 | 
             
                end
         | 
| 44 44 |  | 
| 45 | 
            +
                def FnAnd(array)
         | 
| 46 | 
            +
                  ##
         | 
| 47 | 
            +
                  # Equivalent to the CloudFormation template built in function Fn::And
         | 
| 48 | 
            +
                  if !array || array.count < 2 || array.count > 10
         | 
| 49 | 
            +
                    raise 'The array passed to Fn::And must have at least 2 elements and no more than 10'
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                  Fn.new("And", array)
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                def FnEquals(value1, value2)
         | 
| 55 | 
            +
                  ##
         | 
| 56 | 
            +
                  # Equivalent to the Cloudformation template built in function Fn::Equals
         | 
| 57 | 
            +
                  Fn.new("Equals", [value1, value2])
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                def FnIf(conditionName, trueValue, falseValue)
         | 
| 61 | 
            +
                  ##
         | 
| 62 | 
            +
                  # Equivalent to the Cloudformation template built in function Fn::If
         | 
| 63 | 
            +
                  Fn.new("If", [conditionName, trueValue, falseValue])
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                def FnNot(value)
         | 
| 67 | 
            +
                  ##
         | 
| 68 | 
            +
                  # Equivalent to the Cloudformation template built in function Fn::Not
         | 
| 69 | 
            +
                  Fn.new("Not", value)
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
                def FnOr(array)
         | 
| 73 | 
            +
                  ##
         | 
| 74 | 
            +
                  # Equivalent to the CloudFormation template built in function Fn::Or
         | 
| 75 | 
            +
                  if !array || array.count < 2 || array.count > 10
         | 
| 76 | 
            +
                    raise 'The array passed to Fn::Or must have at least 2 elements and no more than 10'
         | 
| 77 | 
            +
                  end
         | 
| 78 | 
            +
                  Fn.new("Or", array)
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                def FnSelect(index, array)
         | 
| 82 | 
            +
                  ##
         | 
| 83 | 
            +
                  # Equivalent to the CloudFormation template built in function Fn::Select
         | 
| 84 | 
            +
                  Fn.new("Select", [ index, array] )
         | 
| 85 | 
            +
                end
         | 
| 86 | 
            +
             | 
| 45 87 | 
             
                def FnFormat(string, *arguments)
         | 
| 46 88 | 
             
                  ##
         | 
| 47 89 | 
             
                  # Usage
         | 
| 48 90 | 
             
                  #  FnFormat( "This is a %0. It is 100%% %1","test", "effective")
         | 
| 49 91 | 
             
                  # or
         | 
| 50 | 
            -
                  #  FnFormat( "This is a %{test}. It is 100%% %{effective}, | 
| 51 | 
            -
                  #            :test=>"test", | 
| 92 | 
            +
                  #  FnFormat( "This is a %{test}. It is 100%% %{effective},
         | 
| 93 | 
            +
                  #            :test=>"test",
         | 
| 52 94 | 
             
                  #            :effective=>"effective")
         | 
| 53 95 | 
             
                  #
         | 
| 54 96 | 
             
                  # These will each generate a call to Fn::Join that when
         | 
| 55 97 | 
             
                  # evaluated will produce the string "This is a test. It is 100%
         | 
| 56 98 | 
             
                  # effective."
         | 
| 57 99 | 
             
                  #
         | 
| 58 | 
            -
                  # Think of this as %0,%1, etc in the format string being replaced by the | 
| 100 | 
            +
                  # Think of this as %0,%1, etc in the format string being replaced by the
         | 
| 59 101 | 
             
                  # corresponding arguments given after the format string. '%%' is replaced
         | 
| 60 | 
            -
                  # by the '%' character. | 
| 61 | 
            -
                  # | 
| 102 | 
            +
                  # by the '%' character.
         | 
| 103 | 
            +
                  #
         | 
| 62 104 | 
             
                  # The actual Fn::Join call corresponding to the above FnFormat call would be
         | 
| 63 105 | 
             
                  # {"Fn::Join": ["",["This is a ","test",". It is 100","%"," ","effective"]]}
         | 
| 64 106 | 
             
                  #
         | 
| 65 107 | 
             
                  # If no arguments are given, or if a hash is given and the format
         | 
| 66 | 
            -
                  # variable name does not exist in the hash, it is used as a Ref | 
| 108 | 
            +
                  # variable name does not exist in the hash, it is used as a Ref
         | 
| 67 109 | 
             
                  # to an existing resource or parameter.
         | 
| 68 110 | 
             
                  #
         | 
| 69 111 | 
             
                  array = [];
         | 
| @@ -77,7 +119,7 @@ module CfnDsl | |
| 77 119 | 
             
                      elsif( $3 ) then
         | 
| 78 120 | 
             
                        array.push hash[ $4 ] || hash[ $4.to_sym ] || Ref( $4 )
         | 
| 79 121 | 
             
                      end
         | 
| 80 | 
            -
                    end | 
| 122 | 
            +
                    end
         | 
| 81 123 | 
             
                  else
         | 
| 82 124 | 
             
                    string.scan( /(.*?)(%(%|\d+)|\z)/m ) do |x,y|
         | 
| 83 125 | 
             
                      array.push $1 if $1 && $1 != ""
         | 
| @@ -86,7 +128,7 @@ module CfnDsl | |
| 86 128 | 
             
                      elsif( $3 ) then
         | 
| 87 129 | 
             
                        array.push arguments[ $3.to_i ]
         | 
| 88 130 | 
             
                      end
         | 
| 89 | 
            -
                    end | 
| 131 | 
            +
                    end
         | 
| 90 132 | 
             
                  end
         | 
| 91 133 | 
             
                  Fn.new("Join", ["", array])
         | 
| 92 134 | 
             
                end
         | 
| @@ -94,7 +136,7 @@ module CfnDsl | |
| 94 136 |  | 
| 95 137 | 
             
              class JSONable
         | 
| 96 138 | 
             
                ##
         | 
| 97 | 
            -
                # This is the base class for just about everything useful in the | 
| 139 | 
            +
                # This is the base class for just about everything useful in the
         | 
| 98 140 | 
             
                # DSL. It knows how to turn DSL Objects into the corresponding
         | 
| 99 141 | 
             
                # json, and it lets you create new built in function objects
         | 
| 100 142 | 
             
                # from inside the context of a dsl object.
         | 
| @@ -112,7 +154,7 @@ module CfnDsl | |
| 112 154 | 
             
                  hash = {}
         | 
| 113 155 | 
             
                  self.instance_variables.each do |var|
         | 
| 114 156 | 
             
                    name = var[1..-1]
         | 
| 115 | 
            -
             | 
| 157 | 
            +
             | 
| 116 158 | 
             
                    if( name =~ /^__/ ) then
         | 
| 117 159 | 
             
                      # if a variable starts with double underscore, strip one off
         | 
| 118 160 | 
             
                      name = name[1..-1]
         | 
| @@ -120,7 +162,7 @@ module CfnDsl | |
| 120 162 | 
             
                      # Hide variables that start with single underscore
         | 
| 121 163 | 
             
                      name = nil
         | 
| 122 164 | 
             
                    end
         | 
| 123 | 
            -
             | 
| 165 | 
            +
             | 
| 124 166 | 
             
                    hash[name] = self.instance_variable_get var if name
         | 
| 125 167 | 
             
                  end
         | 
| 126 168 | 
             
                  hash.to_json(*a)
         | 
| @@ -134,17 +176,17 @@ module CfnDsl | |
| 134 176 | 
             
                  self.instance_eval &block if block_given?
         | 
| 135 177 | 
             
                end
         | 
| 136 178 |  | 
| 137 | 
            -
                def method_missing(meth,*args,&block) | 
| 179 | 
            +
                def method_missing(meth,*args,&block)
         | 
| 138 180 | 
             
                  if(args) then
         | 
| 139 181 | 
             
                    arg = "(" + args.inspect[1..-2] + ")"
         | 
| 140 | 
            -
                  else | 
| 182 | 
            +
                  else
         | 
| 141 183 | 
             
                    arg = ""
         | 
| 142 184 | 
             
                  end
         | 
| 143 185 | 
             
                  CfnDsl::Errors.error( "Undefined symbol: #{meth}#{arg}", 1 )
         | 
| 144 186 | 
             
                end
         | 
| 145 187 | 
             
              end
         | 
| 146 188 |  | 
| 147 | 
            -
             | 
| 189 | 
            +
             | 
| 148 190 | 
             
              class Fn < JSONable
         | 
| 149 191 | 
             
                ##
         | 
| 150 192 | 
             
                # Handles all of the Fn:: objects
         | 
| @@ -153,7 +195,7 @@ module CfnDsl | |
| 153 195 | 
             
                  @argument = argument
         | 
| 154 196 | 
             
                  @_refs = refs
         | 
| 155 197 | 
             
                end
         | 
| 156 | 
            -
             | 
| 198 | 
            +
             | 
| 157 199 | 
             
                def to_json(*a)
         | 
| 158 200 | 
             
                  hash = {}
         | 
| 159 201 | 
             
                  hash["Fn::#{@function}"] = @argument
         | 
| @@ -172,7 +214,7 @@ module CfnDsl | |
| 172 214 | 
             
              class RefDefinition < JSONable
         | 
| 173 215 | 
             
                ##
         | 
| 174 216 | 
             
                # Handles the Ref objects
         | 
| 175 | 
            -
                def initialize( value ) | 
| 217 | 
            +
                def initialize( value )
         | 
| 176 218 | 
             
                  @Ref = value
         | 
| 177 219 | 
             
                end
         | 
| 178 220 |  | 
| @@ -180,5 +222,5 @@ module CfnDsl | |
| 180 222 | 
             
                  [@Ref]
         | 
| 181 223 | 
             
                end
         | 
| 182 224 | 
             
              end
         | 
| 183 | 
            -
             | 
| 225 | 
            +
             | 
| 184 226 | 
             
            end
         | 
    
        data/lib/cfndsl/Outputs.rb
    CHANGED
    
    | @@ -1,11 +1,11 @@ | |
| 1 1 | 
             
            require 'cfndsl/JSONable'
         | 
| 2 2 |  | 
| 3 | 
            -
            module CfnDsl | 
| 3 | 
            +
            module CfnDsl
         | 
| 4 4 | 
             
              class OutputDefinition < JSONable
         | 
| 5 5 | 
             
                ##
         | 
| 6 6 | 
             
                # Handles Output objects
         | 
| 7 | 
            -
                dsl_attr_setter :Value, :Description
         | 
| 8 | 
            -
             | 
| 7 | 
            +
                dsl_attr_setter :Value, :Description, :Condition
         | 
| 8 | 
            +
             | 
| 9 9 | 
             
                def initialize( value=nil)
         | 
| 10 10 | 
             
                  @Value = value if value
         | 
| 11 11 | 
             
                end
         | 
    
        data/lib/cfndsl/Plurals.rb
    CHANGED
    
    | @@ -8,9 +8,12 @@ module CfnDsl | |
| 8 8 | 
             
                  "Metadata" => "Metadata", 
         | 
| 9 9 | 
             
                  "Property" => "Properties",
         | 
| 10 10 | 
             
                  "Policy" => "Policies",
         | 
| 11 | 
            +
                  "PolicyDocument" => "PolicyDocument",
         | 
| 12 | 
            +
                  "AssumeRolePolicyDocument" => "AssumeRolePolicyDocument",
         | 
| 11 13 | 
             
                  "SecurityGroupIngress" => "SecurityGroupIngress",
         | 
| 12 14 | 
             
                  "SecurityGroupEgress" => "SecurityGroupEgress",
         | 
| 13 | 
            -
                  "DBSecurityGroupIngress" => "DBSecurityGroupIngress"
         | 
| 15 | 
            +
                  "DBSecurityGroupIngress" => "DBSecurityGroupIngress",
         | 
| 16 | 
            +
                  "UpdatePolicy" => "UpdatePolicy"
         | 
| 14 17 | 
             
                }
         | 
| 15 18 |  | 
| 16 19 | 
             
                @@singles = {}
         | 
    
        data/lib/cfndsl/Resources.rb
    CHANGED
    
    | @@ -1,13 +1,14 @@ | |
| 1 1 | 
             
            require 'cfndsl/JSONable'
         | 
| 2 2 | 
             
            require 'cfndsl/Metadata'
         | 
| 3 3 | 
             
            require 'cfndsl/Properties'
         | 
| 4 | 
            +
            require 'cfndsl/UpdatePolicy'
         | 
| 4 5 |  | 
| 5 | 
            -
            module CfnDsl | 
| 6 | 
            +
            module CfnDsl
         | 
| 6 7 | 
             
              class ResourceDefinition < JSONable
         | 
| 7 8 | 
             
                ##
         | 
| 8 9 | 
             
                # Handles Resource objects
         | 
| 9 | 
            -
                dsl_attr_setter :Type, :DependsOn, :DeletionPolicy
         | 
| 10 | 
            -
                dsl_content_object :Property, :Metadata
         | 
| 10 | 
            +
                dsl_attr_setter :Type, :DependsOn, :DeletionPolicy, :Condition
         | 
| 11 | 
            +
                dsl_content_object :Property, :Metadata, :UpdatePolicy
         | 
| 11 12 |  | 
| 12 13 | 
             
                def addTag(name, value, propagate=nil)
         | 
| 13 14 | 
             
                  self.send(:Tag) {
         | 
| @@ -27,7 +28,7 @@ module CfnDsl | |
| 27 28 | 
             
                    end
         | 
| 28 29 |  | 
| 29 30 | 
             
                    if( @DependsOn.instance_of?(String) ) then
         | 
| 30 | 
            -
                      refs.push @DependsOn | 
| 31 | 
            +
                      refs.push @DependsOn
         | 
| 31 32 | 
             
                    end
         | 
| 32 33 | 
             
                  end
         | 
| 33 34 | 
             
                  refs
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            require 'cfndsl/JSONable'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module CfnDsl  
         | 
| 4 | 
            +
              class UpdatePolicyDefinition < JSONable
         | 
| 5 | 
            +
                ##
         | 
| 6 | 
            +
                # Handles autoscaling group update policy objects for Resources
         | 
| 7 | 
            +
                #
         | 
| 8 | 
            +
                # Usage
         | 
| 9 | 
            +
                #   Resource("aaa") {
         | 
| 10 | 
            +
                #     UpdatePolicy("AutoScalingRollingUpdate", {    
         | 
| 11 | 
            +
                #       "MinInstancesInService" => "1",
         | 
| 12 | 
            +
                #       "MaxBatchSize" => "1",
         | 
| 13 | 
            +
                #       "PauseTime" => "PT12M5S"
         | 
| 14 | 
            +
                #     })
         | 
| 15 | 
            +
                #   }
         | 
| 16 | 
            +
                #
         | 
| 17 | 
            +
                def initialize(value) 
         | 
| 18 | 
            +
                  @value = value;
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                def value
         | 
| 22 | 
            +
                  return @value
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
                
         | 
| 25 | 
            +
                def to_json(*a) 
         | 
| 26 | 
            +
                  @value.to_json(*a)
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
    
        data/lib/cfndsl/aws_types.yaml
    CHANGED
    
    | @@ -1,5 +1,7 @@ | |
| 1 1 | 
             
            Resources:
         | 
| 2 2 | 
             
              "AWS::AutoScaling::AutoScalingGroup" :
         | 
| 3 | 
            +
               UpdatePolicy:
         | 
| 4 | 
            +
                AutoScalingRollingUpdate: JSON
         | 
| 3 5 | 
             
               Properties:
         | 
| 4 6 | 
             
                AvailabilityZones: [ String ]
         | 
| 5 7 | 
             
                Cooldown: String
         | 
| @@ -7,7 +9,7 @@ Resources: | |
| 7 9 | 
             
                HealthCheckGracePeriod: Integer
         | 
| 8 10 | 
             
                HealthCheckType: String
         | 
| 9 11 | 
             
                LaunchConfigurationName: String
         | 
| 10 | 
            -
                 | 
| 12 | 
            +
                LoadBalancerNames: [ String ]
         | 
| 11 13 | 
             
                MaxSize: Integer
         | 
| 12 14 | 
             
                MinSize: Integer
         | 
| 13 15 | 
             
                NotificationConfiguration: String
         | 
| @@ -15,21 +17,32 @@ Resources: | |
| 15 17 | 
             
                VPCZoneIdentifier: [ String ]
         | 
| 16 18 | 
             
              "AWS::AutoScaling::LaunchConfiguration" :
         | 
| 17 19 | 
             
                Properties:
         | 
| 20 | 
            +
                 AssociatePublicIpAddress: Boolean
         | 
| 18 21 | 
             
                 BlockDeviceMappings: [ BlockDeviceMapping ]
         | 
| 19 22 | 
             
                 ImageId: String
         | 
| 23 | 
            +
                 InstanceMonitoring: Boolean
         | 
| 20 24 | 
             
                 InstanceType: String
         | 
| 21 25 | 
             
                 KernelId: String
         | 
| 22 26 | 
             
                 KeyName: String
         | 
| 23 27 | 
             
                 RamDiskId: String
         | 
| 24 28 | 
             
                 SecurityGroups: [ String ]
         | 
| 25 29 | 
             
                 UserData: String
         | 
| 26 | 
            -
              "AWS:: | 
| 30 | 
            +
              "AWS::AutoScaling::ScalingPolicy" :
         | 
| 27 31 | 
             
               Properties:
         | 
| 28 32 | 
             
                AdjustmentType: String
         | 
| 29 33 | 
             
                AutoScalingGroupName: String
         | 
| 30 34 | 
             
                Cooldown: String
         | 
| 31 35 | 
             
                ScalingAdjustment: String
         | 
| 32 | 
            -
              "AWS:: | 
| 36 | 
            +
              "AWS::AutoScaling::ScheduledAction" :
         | 
| 37 | 
            +
               Properties:
         | 
| 38 | 
            +
                AutoScalingGroupName: String
         | 
| 39 | 
            +
                DesiredCapacity: Integer
         | 
| 40 | 
            +
                EndTime: String
         | 
| 41 | 
            +
                MaxSize: Integer
         | 
| 42 | 
            +
                MinSize: Integer
         | 
| 43 | 
            +
                Recurrence: String
         | 
| 44 | 
            +
                StartTime: String
         | 
| 45 | 
            +
              "AWS::AutoScaling::Trigger" :
         | 
| 33 46 | 
             
               Properties:
         | 
| 34 47 | 
             
                Dimensions: [ MetricDimension ]
         | 
| 35 48 | 
             
                MetricName: String
         | 
| @@ -93,11 +106,13 @@ Resources: | |
| 93 106 | 
             
               Properties:
         | 
| 94 107 | 
             
                AvailabilityZone: String
         | 
| 95 108 | 
             
                DisableApiTermination: String
         | 
| 109 | 
            +
                IamInstanceProfile: String
         | 
| 96 110 | 
             
                ImageId: String
         | 
| 97 111 | 
             
                InstanceType: String
         | 
| 98 112 | 
             
                KernelId: String
         | 
| 99 113 | 
             
                KeyName: String
         | 
| 100 114 | 
             
                Monitoring: String
         | 
| 115 | 
            +
                NetworkInterfaces: JSON
         | 
| 101 116 | 
             
                PlacementGroupName: String
         | 
| 102 117 | 
             
                PrivateIpAddress: String
         | 
| 103 118 | 
             
                RamDiskId: String
         | 
| @@ -143,7 +158,7 @@ Resources: | |
| 143 158 | 
             
                DestinationSecurityGroupId: String
         | 
| 144 159 | 
             
                FromPort: Number
         | 
| 145 160 | 
             
                ToPort: Number
         | 
| 146 | 
            -
              "AWS::EC2::SecurityGroupIngress":
         | 
| 161 | 
            +
              "AWS::EC2::SecurityGroupIngress" :
         | 
| 147 162 | 
             
               Properties:
         | 
| 148 163 | 
             
                GroupName: String
         | 
| 149 164 | 
             
                GroupId: String
         | 
| @@ -206,7 +221,7 @@ Resources: | |
| 206 221 | 
             
              "AWS::ElastiCache::SecurityGroup" :
         | 
| 207 222 | 
             
               Properties:
         | 
| 208 223 | 
             
                Decription: String
         | 
| 209 | 
            -
              "AWS::ElastiCache:: | 
| 224 | 
            +
              "AWS::ElastiCache::SecurityGroupIngress" :
         | 
| 210 225 | 
             
               Properties:
         | 
| 211 226 | 
             
                CacheSecurityGroupName: String
         | 
| 212 227 | 
             
                EC2SecurityGroupName: String
         | 
| @@ -227,11 +242,13 @@ Resources: | |
| 227 242 | 
             
              "AWS::ElasticLoadBalancing::LoadBalancer" :
         | 
| 228 243 | 
             
               Properties:
         | 
| 229 244 | 
             
                AvailabilityZones: [String]
         | 
| 245 | 
            +
                CrossZone: Boolean
         | 
| 230 246 | 
             
                HealthCheck: HealthCheck
         | 
| 231 247 | 
             
                Instances: [String]
         | 
| 232 248 | 
             
                Listeners: [ Listener ]
         | 
| 233 249 | 
             
                AppCookieStickinessPolicy: AppCookieStickinessPolicy
         | 
| 234 250 | 
             
                LBCookieStickinessPolicy:  LBCookieStickinessPolicy
         | 
| 251 | 
            +
                Scheme: String
         | 
| 235 252 | 
             
                SecurityGroups: [ String ]
         | 
| 236 253 | 
             
                Subnets: [ String ]
         | 
| 237 254 | 
             
               Attributes:
         | 
| @@ -253,15 +270,28 @@ Resources: | |
| 253 270 | 
             
                Policies: [ IAMEmbeddedPolicy ]
         | 
| 254 271 | 
             
               Attributes:
         | 
| 255 272 | 
             
                Arn : String
         | 
| 273 | 
            +
              "AWS::IAM::InstanceProfile" :
         | 
| 274 | 
            +
               Properties:
         | 
| 275 | 
            +
                Path: String
         | 
| 276 | 
            +
                Roles: [ String ]
         | 
| 277 | 
            +
               Attributes:
         | 
| 278 | 
            +
                Arn : String    
         | 
| 256 279 | 
             
              "AWS::IAM::Policy" :
         | 
| 257 280 | 
             
               Properties:
         | 
| 258 281 | 
             
                PolicyName: String
         | 
| 259 | 
            -
                 | 
| 282 | 
            +
                PolicyDocument: JSON
         | 
| 260 283 | 
             
                Groups: [ String ]
         | 
| 261 284 | 
             
                Users: [ String ]
         | 
| 285 | 
            +
              "AWS::IAM::Role" :
         | 
| 286 | 
            +
               Properties:
         | 
| 287 | 
            +
                AssumeRolePolicyDocument: JSON
         | 
| 288 | 
            +
                Path: String
         | 
| 289 | 
            +
                Policies: [ IAMEmbeddedPolicy ]
         | 
| 290 | 
            +
               Attributes:
         | 
| 291 | 
            +
                Arn : String    
         | 
| 262 292 | 
             
              "AWS::IAM::UserToGroupAddition" :
         | 
| 263 293 | 
             
               Properties:
         | 
| 264 | 
            -
                 | 
| 294 | 
            +
                GroupName: String
         | 
| 265 295 | 
             
                Users: [String]
         | 
| 266 296 | 
             
              "AWS::IAM::User" :
         | 
| 267 297 | 
             
               Properties:
         | 
| @@ -475,8 +505,3 @@ Types: | |
| 475 505 | 
             
             IAMEmbeddedPolicy:
         | 
| 476 506 | 
             
              PolicyDocument: JSON
         | 
| 477 507 | 
             
              PolicyName: String
         | 
| 478 | 
            -
             | 
| 479 | 
            -
             
         | 
| 480 | 
            -
              
         | 
| 481 | 
            -
             
         | 
| 482 | 
            -
             
         | 
    
        metadata
    CHANGED
    
    | @@ -1,8 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: cfndsl
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0 | 
| 5 | 
            -
              prerelease: 
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 6 5 | 
             
            platform: ruby
         | 
| 7 6 | 
             
            authors:
         | 
| 8 7 | 
             
            - Chris Howe
         | 
| @@ -10,7 +9,35 @@ autorequire: | |
| 10 9 | 
             
            bindir: bin
         | 
| 11 10 | 
             
            cert_chain: []
         | 
| 12 11 | 
             
            date: 2013-05-16 00:00:00.000000000 Z
         | 
| 13 | 
            -
            dependencies: | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: rake
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - '>='
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - '>='
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: test-unit
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - '>='
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - '>='
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 14 41 | 
             
            description: DSL for creating AWS Cloudformation templates
         | 
| 15 42 | 
             
            email: chris@howeville.com
         | 
| 16 43 | 
             
            executables:
         | 
| @@ -25,6 +52,7 @@ files: | |
| 25 52 | 
             
            - lib/cfndsl/RefCheck.rb
         | 
| 26 53 | 
             
            - lib/cfndsl/Types.rb
         | 
| 27 54 | 
             
            - lib/cfndsl/Properties.rb
         | 
| 55 | 
            +
            - lib/cfndsl/Conditions.rb
         | 
| 28 56 | 
             
            - lib/cfndsl/Mappings.rb
         | 
| 29 57 | 
             
            - lib/cfndsl/Resources.rb
         | 
| 30 58 | 
             
            - lib/cfndsl/Metadata.rb
         | 
| @@ -34,29 +62,29 @@ files: | |
| 34 62 | 
             
            - lib/cfndsl/Plurals.rb
         | 
| 35 63 | 
             
            - lib/cfndsl/names.rb
         | 
| 36 64 | 
             
            - lib/cfndsl/CloudFormationTemplate.rb
         | 
| 65 | 
            +
            - lib/cfndsl/UpdatePolicy.rb
         | 
| 37 66 | 
             
            - bin/cfndsl
         | 
| 38 | 
            -
            homepage: https://github.com/ | 
| 67 | 
            +
            homepage: https://github.com/stevenjack/cfndsl
         | 
| 39 68 | 
             
            licenses: []
         | 
| 69 | 
            +
            metadata: {}
         | 
| 40 70 | 
             
            post_install_message: 
         | 
| 41 71 | 
             
            rdoc_options: []
         | 
| 42 72 | 
             
            require_paths:
         | 
| 43 73 | 
             
            - lib
         | 
| 44 74 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 45 | 
            -
              none: false
         | 
| 46 75 | 
             
              requirements:
         | 
| 47 | 
            -
              - -  | 
| 76 | 
            +
              - - '>='
         | 
| 48 77 | 
             
                - !ruby/object:Gem::Version
         | 
| 49 78 | 
             
                  version: '0'
         | 
| 50 79 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 51 | 
            -
              none: false
         | 
| 52 80 | 
             
              requirements:
         | 
| 53 | 
            -
              - -  | 
| 81 | 
            +
              - - '>='
         | 
| 54 82 | 
             
                - !ruby/object:Gem::Version
         | 
| 55 83 | 
             
                  version: '0'
         | 
| 56 84 | 
             
            requirements: []
         | 
| 57 85 | 
             
            rubyforge_project: 
         | 
| 58 | 
            -
            rubygems_version:  | 
| 86 | 
            +
            rubygems_version: 2.0.3
         | 
| 59 87 | 
             
            signing_key: 
         | 
| 60 | 
            -
            specification_version:  | 
| 88 | 
            +
            specification_version: 4
         | 
| 61 89 | 
             
            summary: AWS Cloudformation DSL
         | 
| 62 90 | 
             
            test_files: []
         |