holy-lambda

Chris Lowe 2022-06-03T10:16:57.528269Z

I have a lambda with a Babashka runtime but it’s failing at runtime:

1: (ns example.core
2022-06-03T10:39:54.221+01:00	2: (:gen-class)
2022-06-03T10:39:54.221+01:00	3: (:require
2022-06-03T10:39:54.221+01:00	^--- Could not find namespace: fierycod.holy-lambda.response.
2022-06-03T10:39:54.221+01:00	4: [babashka.pods :as pods]
2022-06-03T10:39:54.221+01:00	5: [fierycod.holy-lambda.response :as hr]
2022-06-03T10:39:54.221+01:00	6: [fierycod.holy-lambda.core :as h]
2022-06-03T10:39:54.221+01:00	7: ;; shipped with Babashka, hence no dependency in deps.edn
2022-06-03T10:39:54.221+01:00	8: [hiccup.core :as hiccup]))

Chris Lowe 2022-06-03T10:18:59.980339Z

the relevant bit in my template.yml

Resources:
  BabashkaDepsLayer:
    Type: AWS::Serverless::LayerVersion
    Properties:
      LayerName: BabashkaDepsLayer
      ContentUri: ./.holy-lambda/bb-clj-deps

  BabashkaPodsLayer:
    Type: AWS::Serverless::LayerVersion
    Properties:
      LayerName: BabashkaPodsLayer
      Description: Shared pods for stack.
      ContentUri: ./.holy-lambda/pods
      CompatibleRuntimes:
        - provided.al2

ExampleLambdaFunction:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: "ExampleLambda"
      Runtime: provided.al2
      Architectures:
        - arm64
      Handler: example.core.ExampleLambda
      CodeUri: src
      Timeout: 40
      MemorySize: 2048
      Events:
        GetEvent:
          Type: HttpApi
          Properties:
            ApiId: !Ref ExampleHttpApi
            Path: /my-path/{id}
            Method: GET
      Layers:
        - !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:layer:holy-lambda-babashka-runtime-arm64:1"
        - !Ref BabashkaDepsLayer
        - !Ref BabashkaPodsLayer

Chris Lowe 2022-06-03T10:20:02.188909Z

I’d deployed the ARM runtime to my account via this link:

Chris Lowe 2022-06-03T10:21:35.631819Z

I’m using the HL layer, so it’s strange that the namespace fierycod.holy-lambda.response is reported as something that cannot be found.

Chris Lowe 2022-06-03T10:21:52.857359Z

This is using HL 0.6.6 with latest tasks

Karol Wójcik 2022-06-03T10:27:53.445049Z

The latest BB runtimes are not shipping HL directly.

Chris Lowe 2022-06-03T10:28:10.073359Z

ah, ok

Karol Wójcik 2022-06-03T10:28:12.342099Z

You have to include the dependency in bb.edn 🙂

Chris Lowe 2022-06-03T10:29:17.197319Z

what do I need to include?

Karol Wójcik 2022-06-03T10:29:32.651469Z

HL dependency

Chris Lowe 2022-06-03T10:30:26.566409Z

Hmmm - I already have it:

:deps    {org.clojure/clojure                  {:mvn/version "1.11.1"}
           io.github.FieryCod/holy-lambda       {:mvn/version "0.6.6"}
           com.github.clj-easy/graal-build-time {:mvn/version "0.1.4"}}

Chris Lowe 2022-06-03T10:30:48.343209Z

I’ll try without the graal-build-time

Chris Lowe 2022-06-03T10:31:03.675959Z

I assume Clojure 1.11.1 is ok?

Karol Wójcik 2022-06-03T10:31:06.645259Z

Do you have it in bb.edn?

Chris Lowe 2022-06-03T10:31:57.371259Z

Nothing explicit for HL in bb.deps

Chris Lowe 2022-06-03T10:32:26.536659Z

is there a specific pod I need to add?

Karol Wójcik 2022-06-03T10:32:27.835509Z

You need to place io.github.FieryCod/holy-lambda {:mvn/version "0.6.6"} in bb.edn deps

Karol Wójcik 2022-06-03T10:32:48.188389Z

This is because for babashka runtime the BB is handling deps not HL tasks

Chris Lowe 2022-06-03T10:33:36.561119Z

> This is because for babashka runtime the BB is handling deps not HL. Which is something I always forget!

Chris Lowe 2022-06-03T10:38:39.989889Z

Perfect - that worked. Thank you @karol.wojcik

Karol Wójcik 2022-06-03T10:41:05.955119Z

You are very welcome 🙂