Class: Convection::Model::Mixin::Policy::Statement
- Inherits:
-
Object
- Object
- Convection::Model::Mixin::Policy::Statement
- Includes:
- DSL::Helpers
- Defined in:
- lib/convection/model/mixin/policy.rb
Overview
An IAM policy statement
Instance Method Summary collapse
-
#initialize(effect = 'Allow', template = nil) ⇒ Statement
constructor
A new instance of Statement.
- #render ⇒ Object
- #s3_resource(bucket, path = nil) ⇒ Object
- #sns_resource(region, account, topic) ⇒ Object
- #sqs_resource(region, account, queue) ⇒ Object
Methods included from DSL::Helpers
#camel_case, included, method_name, #screaming_snake_case, #snake_case
Methods included from DSL::IntrinsicFunctions
#base64, #find_in_map, #fn_and, #fn_equals, #fn_if, #fn_not, #fn_or, #fn_ref, #get_att, #get_azs, #join, #select
Constructor Details
#initialize(effect = 'Allow', template = nil) ⇒ Statement
Returns a new instance of Statement
84 85 86 87 88 89 90 91 |
# File 'lib/convection/model/mixin/policy.rb', line 84 def initialize(effect = 'Allow', template = nil) @effect = effect @action = [] @resource = [] @template = template end |
Instance Method Details
#render ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/convection/model/mixin/policy.rb', line 93 def render { 'Effect' => effect, '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 |
#s3_resource(bucket, path = nil) ⇒ Object
71 72 73 74 |
# File 'lib/convection/model/mixin/policy.rb', line 71 def s3_resource(bucket, path = nil) return resource "arn:aws:s3:::#{ bucket }/#{ path }" unless path.nil? resource "arn:aws:s3:::#{ bucket }" end |
#sns_resource(region, account, topic) ⇒ Object
80 81 82 |
# File 'lib/convection/model/mixin/policy.rb', line 80 def sns_resource(region, account, topic) resource "arn:aws:sns:#{ region }:#{ account }:#{ topic }" end |
#sqs_resource(region, account, queue) ⇒ Object
76 77 78 |
# File 'lib/convection/model/mixin/policy.rb', line 76 def sqs_resource(region, account, queue) resource "arn:aws:sqs:#{ region }:#{ account }:#{ queue }" end |