Sha256: dab27a237c77be4e6184691634157a2d35dda1d09470b926d73c740983758f50

Contents?: true

Size: 1.35 KB

Versions: 37

Compression:

Stored size: 1.35 KB

Contents

module Jets::Resource::ApiGateway::BasePath
  class Function < Jets::Resource::Base
    include Jets::Resource::Lambda::Function::Environment

    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

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

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

    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

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

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

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
jets-4.0.12 lib/jets/resource/api_gateway/base_path/function.rb
jets-4.0.11 lib/jets/resource/api_gateway/base_path/function.rb
jets-4.0.10 lib/jets/resource/api_gateway/base_path/function.rb
jets-4.0.9 lib/jets/resource/api_gateway/base_path/function.rb
jets-4.0.8 lib/jets/resource/api_gateway/base_path/function.rb
jets-4.0.7 lib/jets/resource/api_gateway/base_path/function.rb
jets-4.0.6 lib/jets/resource/api_gateway/base_path/function.rb
jets-4.0.5 lib/jets/resource/api_gateway/base_path/function.rb
jets-4.0.4 lib/jets/resource/api_gateway/base_path/function.rb
jets-4.0.3 lib/jets/resource/api_gateway/base_path/function.rb
jets-4.0.2 lib/jets/resource/api_gateway/base_path/function.rb
jets-4.0.1 lib/jets/resource/api_gateway/base_path/function.rb
jets-4.0.0 lib/jets/resource/api_gateway/base_path/function.rb
jets-3.2.2 lib/jets/resource/api_gateway/base_path/function.rb
jets-3.2.1 lib/jets/resource/api_gateway/base_path/function.rb
jets.benforeva-3.0.17.pre.mount.pre.fix lib/jets/resource/api_gateway/base_path/function.rb
jets-3.2.0 lib/jets/resource/api_gateway/base_path/function.rb
jets-3.1.5 lib/jets/resource/api_gateway/base_path/function.rb
jets-3.1.4 lib/jets/resource/api_gateway/base_path/function.rb
jets-3.1.3 lib/jets/resource/api_gateway/base_path/function.rb