Class: Jets::Resource::Permission
- Defined in:
- lib/jets/resource/permission.rb
Instance Method Summary collapse
- #definition ⇒ Object
-
#initialize(replacements, associated_resource) ⇒ Permission
constructor
A new instance of Permission.
- #permission_logical_id ⇒ Object
-
#principal ⇒ Object
Auto-detect principal from the associated resources.
- #source_arn ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(replacements, associated_resource) ⇒ Permission
Returns a new instance of Permission.
3 4 5 6 |
# File 'lib/jets/resource/permission.rb', line 3 def initialize(replacements, associated_resource) @replacements = replacements @associated_resource = associated_resource end |
Instance Method Details
#definition ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/jets/resource/permission.rb', line 8 def definition logical_id = definition = { logical_id => { type: "AWS::Lambda::Permission", properties: { function_name: "!GetAtt {namespace}LambdaFunction.Arn", action: "lambda:InvokeFunction", principal: principal } } } # From AWS docs: https://amzn.to/2N0QXQL # source_arn is "not supported by all event sources" definition[logical_id][:properties][:source_arn] = source_arn if source_arn definition end |
#permission_logical_id ⇒ Object
29 30 31 32 33 34 |
# File 'lib/jets/resource/permission.rb', line 29 def logical_id = "{namespace}_permission" md = @associated_resource.logical_id.match(/(\d+)/) counter = md[1] if md [logical_id, counter].compact.join('').underscore end |
#principal ⇒ Object
Auto-detect principal from the associated resources.
37 38 39 |
# File 'lib/jets/resource/permission.rb', line 37 def principal Replacer.principal_map(@associated_resource.type) end |
#source_arn ⇒ Object
41 42 43 |
# File 'lib/jets/resource/permission.rb', line 41 def source_arn Replacer.source_arn_map(@associated_resource.type) end |