Class: Jets::Cfn::TemplateMappers::IamPolicy::FunctionPolicyMapper

Inherits:
BasePolicyMapper
  • Object
show all
Defined in:
lib/jets/cfn/template_mappers/iam_policy/function_policy_mapper.rb

Instance Method Summary collapse

Methods inherited from BasePolicyMapper

#classify_name, #namespace, #properties

Constructor Details

#initialize(task) ⇒ FunctionPolicyMapper

Returns a new instance of FunctionPolicyMapper.



10
11
12
13
14
# File 'lib/jets/cfn/template_mappers/iam_policy/function_policy_mapper.rb', line 10

def initialize(task)
  @task = task
  @app_class = task.class_name.to_s
  # IE: @app_class: PostsController, HardJob, Hello, HelloFunction
end

Instance Method Details

#iam_policyObject



16
17
18
# File 'lib/jets/cfn/template_mappers/iam_policy/function_policy_mapper.rb', line 16

def iam_policy
  Jets::Cfn::TemplateBuilders::IamPolicy::FunctionPolicy.new(@task)
end

#logical_idObject

Example: PostsControllerShowLambdaFunction There should be no namespace in the logical_id.



23
24
25
# File 'lib/jets/cfn/template_mappers/iam_policy/function_policy_mapper.rb', line 23

def logical_id
  classify_name("#{@app_class}_#{@task.meth}_iam_role")
end

#role_nameObject

There should be namespace in the role_name.



28
29
30
# File 'lib/jets/cfn/template_mappers/iam_policy/function_policy_mapper.rb', line 28

def role_name
  classify_name("#{namespace}_#{@app_class}_#{@task.meth}_iam_role").underscore.dasherize
end