lib/convection/model/mixin/policy.rb in convection-0.2.11 vs lib/convection/model/mixin/policy.rb in convection-0.2.12

- old
+ new

@@ -1,5 +1,7 @@ +require 'securerandom' + module Convection module Model module Mixin ## # Add definition helpers for entities with policies @@ -59,10 +61,11 @@ include DSL::Helpers attribute :sid attribute :effect attribute :principal + attribute :not_principal attribute :condition list :action list :resource def s3_resource(bucket, path = nil) @@ -88,15 +91,16 @@ end def render { 'Effect' => effect, - 'Action' => action, - 'Resource' => resource - }.tap do |statemant| - statemant['Sid'] = sid unless sid.nil? - statemant['Condition'] = condition unless condition.nil? - statemant['Principal'] = principal unless principal.nil? + 'Action' => action + }.tap do |statement| + statement['Sid'] = sid unless sid.nil? + statement['Condition'] = condition unless condition.nil? + statement['Principal'] = principal unless principal.nil? + statement['NotPrincipal'] = not_principal unless not_principal.nil? + statement['Resource'] = resource unless resource.empty? # Avoid failure in CF if empty Resources array is passed end end end end end