Class: Jets::Cfn::Resource::One::Function
- Inherits:
-
Lambda::Function
- Object
- Base
- Lambda::Function
- Jets::Cfn::Resource::One::Function
- Includes:
- Lambda::Function::Environment
- Defined in:
- lib/jets/cfn/resource/one/function.rb
Constant Summary
Constants inherited from Lambda::Function
Lambda::Function::MAX_FUNCTION_NAME_SIZE
Instance Method Summary collapse
- #application_controller_properties ⇒ Object
-
#combined_properties ⇒ Object
override.
-
#finalize_properties!(props) ⇒ Object
Properties managed by Jets merged with finality.
-
#function_logical_id ⇒ Object
override.
-
#function_name ⇒ Object
Examples: “#Jets.project_namespace-sleep_job-perform” “demo-dev-sleep_job-perform”.
-
#get_runtime(props) ⇒ Object
override.
-
#initialize ⇒ Function
constructor
override to use the same function name for all controllers.
-
#replacements ⇒ Object
override.
Methods included from Lambda::Function::Environment
#env_properties, #environment, #jets_env
Methods inherited from Lambda::Function
#assign_iam_role?, #class_properties, #code_s3_key, #default_description, #default_handler, #default_runtime, default_runtimes, #definition, #full_handler, #function_properties, #get_descripton, #get_layers, #global_properties, #handler, #handler_value, #lookup_class_properties, #one_lambda_per_controller?
Methods inherited from Base
#attributes, #logical_id, #outputs, #parameters, #permission, #properties, #replacer, #standarize, #template, truncate_id, #type
Methods included from Util::Camelize
Constructor Details
#initialize ⇒ Function
override to use the same function name for all controllers
6 7 |
# File 'lib/jets/cfn/resource/one/function.rb', line 6 def initialize end |
Instance Method Details
#application_controller_properties ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/jets/cfn/resource/one/function.rb', line 22 def application_controller_properties klass = ApplicationController return {} unless klass.build_class_iam? class_properties = lookup_class_properties(klass) iam_policy = Jets::Cfn::Resource::Iam::ClassRole.new(klass) class_properties[:Role] = "!GetAtt #{iam_policy.logical_id}.Arn" camelize(class_properties) end |
#combined_properties ⇒ Object
override
15 16 17 18 19 20 |
# File 'lib/jets/cfn/resource/one/function.rb', line 15 def combined_properties props = env_properties .deep_merge(global_properties) .deep_merge(application_controller_properties) finalize_properties!(props) end |
#finalize_properties!(props) ⇒ Object
Properties managed by Jets merged with finality.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/jets/cfn/resource/one/function.rb', line 33 def finalize_properties!(props) handler = "handlers/controller.lambda_handler" runtime = get_runtime(props) description = "Jets Lambda function for all controllers" managed = { Handler: handler, Runtime: runtime, Description: description, } managed[:FunctionName] = function_name if function_name layers = get_layers(runtime) managed[:Layers] = layers if layers props.merge!(managed) end |
#function_logical_id ⇒ Object
override
10 11 12 |
# File 'lib/jets/cfn/resource/one/function.rb', line 10 def function_logical_id "JetsControllerLambdaFunction" end |
#function_name ⇒ Object
Examples:
"#{Jets.project_namespace}-sleep_job-perform"
"demo-dev-sleep_job-perform"
56 57 58 59 |
# File 'lib/jets/cfn/resource/one/function.rb', line 56 def function_name return if ENV['JETS_RESET'] # reset mode, let CloudFormation manage the function name "#{Jets.project_namespace}-controller" end |
#get_runtime(props) ⇒ Object
override
49 50 51 |
# File 'lib/jets/cfn/resource/one/function.rb', line 49 def get_runtime(props) props[:Runtime] || Jets.ruby_runtime end |
#replacements ⇒ Object
override
62 63 64 |
# File 'lib/jets/cfn/resource/one/function.rb', line 62 def replacements {} end |