Class: Bauble::Resources::LambdaRole
- Defined in:
- lib/bauble/resources/lambda_role.rb
Overview
aws lambda role
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#managed_policy_arns ⇒ Object
Returns the value of attribute managed_policy_arns.
-
#name ⇒ Object
Returns the value of attribute name.
-
#policy_statements ⇒ Object
Returns the value of attribute policy_statements.
Attributes inherited from Resource
Instance Method Summary collapse
- #add_policy_statement(effect:, actions:, resources:) ⇒ Object
- #bundle ⇒ Object
-
#initialize(app, name:, policy_statements: [], **kwargs) ⇒ LambdaRole
constructor
A new instance of LambdaRole.
- #synthesize ⇒ Object
Methods inherited from Resource
Constructor Details
#initialize(app, name:, policy_statements: [], **kwargs) ⇒ LambdaRole
Returns a new instance of LambdaRole.
12 13 14 15 16 17 18 |
# File 'lib/bauble/resources/lambda_role.rb', line 12 def initialize(app, name:, policy_statements: [], **kwargs) super(app) @name = name @policy_statements = policy_statements @managed_policy_arns = [] @description = kwargs.fetch(:description, 'Bauble lambda role') end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
10 11 12 |
# File 'lib/bauble/resources/lambda_role.rb', line 10 def description @description end |
#managed_policy_arns ⇒ Object
Returns the value of attribute managed_policy_arns.
10 11 12 |
# File 'lib/bauble/resources/lambda_role.rb', line 10 def managed_policy_arns @managed_policy_arns end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/bauble/resources/lambda_role.rb', line 10 def name @name end |
#policy_statements ⇒ Object
Returns the value of attribute policy_statements.
10 11 12 |
# File 'lib/bauble/resources/lambda_role.rb', line 10 def policy_statements @policy_statements end |
Instance Method Details
#add_policy_statement(effect:, actions:, resources:) ⇒ Object
40 41 42 |
# File 'lib/bauble/resources/lambda_role.rb', line 40 def add_policy_statement(effect:, actions:, resources:) policy_statements << { effect: effect, actions: actions, resources: resources } end |
#bundle ⇒ Object
44 45 46 |
# File 'lib/bauble/resources/lambda_role.rb', line 44 def bundle true end |
#synthesize ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bauble/resources/lambda_role.rb', line 20 def synthesize role_hash = { name => { 'type' => 'aws:iam:Role', 'properties' => { 'name' => resource_name(name), 'assumeRolePolicy' => assume_role_policy, 'managedPolicyArns' => managed_policy_arns.push( 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole' ), 'description' => @description }.compact } } return role_hash.merge(role_policy) if policy_statements.any? role_hash end |