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_import_value, #fn_not, #fn_or, #fn_ref, #fn_sub, #get_att, #get_azs, #join, #select
Constructor Details
#initialize(effect = 'Allow', template = nil) ⇒ Statement
Returns a new instance of Statement.
86 87 88 89 90 91 92 93 |
# File 'lib/convection/model/mixin/policy.rb', line 86 def initialize(effect = 'Allow', template = nil) @effect = effect @action = [] @resource = [] @template = template end |
Instance Method Details
#render ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/convection/model/mixin/policy.rb', line 95 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
73 74 75 76 |
# File 'lib/convection/model/mixin/policy.rb', line 73 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
82 83 84 |
# File 'lib/convection/model/mixin/policy.rb', line 82 def sns_resource(region, account, topic) resource "arn:aws:sns:#{ region }:#{ account }:#{ topic }" end |
#sqs_resource(region, account, queue) ⇒ Object
78 79 80 |
# File 'lib/convection/model/mixin/policy.rb', line 78 def sqs_resource(region, account, queue) resource "arn:aws:sqs:#{ region }:#{ account }:#{ queue }" end |