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



44
45
46
47
# File 'lib/jets/resource/api_gateway/base_path/function.rb', line 44

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
25
# 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: Jets.ruby_runtime,
        timeout: 60,
        memory_size: 1536,
        environment: env_properties[:environment],
        layers: layers,
      }
    }
  }
end

#function_nameObject



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

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



40
41
42
# File 'lib/jets/resource/api_gateway/base_path/function.rb', line 40

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

#layersObject



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

def layers
  return Jets.config.lambda.layers if Jets.config.gems.disable

  ["!Ref GemLayer"] + Jets.config.lambda.layers
end