Class: Jets::Resource::ApiGateway::BasePath::Function

Inherits:
Base
  • Object
show all
Includes:
Lambda::Function::Environment
Defined in:
lib/jets/resource/api_gateway/base_path/function.rb

Instance Method Summary collapse

Methods included from Lambda::Function::Environment

#env_properties, #environment, #jets_env

Methods inherited from Base

#replacements, #resource

Instance Method Details

#code_s3_keyObject



37
38
39
40
# File 'lib/jets/resource/api_gateway/base_path/function.rb', line 37

def code_s3_key
  checksum = Jets::Builders::Md5.checksums["stage/code"]
  "jets/code/code-#{checksum}.zip" # s3_key
end

#definitionObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/jets/resource/api_gateway/base_path/function.rb', line 5

def definition
  {
    base_path_function: {
      type: "AWS::Lambda::Function",
      properties: {
        function_name: function_name,
        code: {
          s3_bucket: "!Ref S3Bucket",
          s3_key: code_s3_key,
        },
        role: "!GetAtt BasePathRole.Arn",
        handler: handler,
        runtime: "ruby2.5",
        timeout: 60,
        memory_size: 1536,
        environment: env_properties[:environment],
      }
    }
  }
end

#function_nameObject



26
27
28
29
30
31
# File 'lib/jets/resource/api_gateway/base_path/function.rb', line 26

def function_name
  method = "jets-base-path"
  # need to add the deployment timestamp because or else function name collides between deploys
  timestamp = Jets::Resource::ApiGateway::Deployment.timestamp
  "#{Jets.config.project_namespace}-#{method}-#{timestamp}"
end

#handlerObject



33
34
35
# File 'lib/jets/resource/api_gateway/base_path/function.rb', line 33

def handler
  "handlers/functions/jets/base_path.lambda_handler"
end