This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-16
Channels
- # ai (5)
- # announcements (47)
- # aws (11)
- # babashka (20)
- # beginners (85)
- # biff (1)
- # calva (72)
- # cider (9)
- # clj-kondo (37)
- # cljfx (9)
- # cljs-dev (1)
- # clojars (2)
- # clojure (61)
- # clojure-berlin (2)
- # clojure-europe (189)
- # clojure-nl (1)
- # clojure-norway (17)
- # clojure-uk (2)
- # clojurescript (51)
- # conjure (3)
- # cursive (4)
- # data-science (6)
- # datomic (6)
- # events (5)
- # fulcro (16)
- # gratitude (9)
- # holy-lambda (9)
- # introduce-yourself (6)
- # lsp (13)
- # malli (8)
- # membrane (2)
- # off-topic (47)
- # pedestal (11)
- # re-frame (15)
- # reitit (1)
- # releases (2)
- # rewrite-clj (6)
- # rum (4)
- # shadow-cljs (2)
- # tools-deps (3)
- # xtdb (25)
- # yada (13)
Jo I'm trying to get the example babashka running https://fierycod.github.io/holy-lambda/#/babashka-backend-tutorial Getting an error that my namespace / file is not found
✔️ 2
[benj@benj-pc holy-lambda-example]$ sam local invoke ExampleLambdaFunction
Invoking com.company.example-lambda.core.ExampleLambda (provided)
arn:aws:lambda:us-east-1:605060902952:layer:holy-lambda-babashka-runtime-amd64:1 is already cached. Skipping download
BabashkaDepsLayer is a local Layer in the template
Building image...........................
Skip pulling image and use local one: samcli/lambda:provided-x86_64-9799d420893c7c1d29497b469.
Mounting /home/benj/repos/clojure/holy-lambda-example/.holy-lambda/build/latest.zip as /var/task:ro,delegated inside runtime container
START RequestId: 0e8b5797-79cf-46e9-b933-ea36145ae82a Version: $LATEST
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: Could not find namespace: com.company.example-lambda.core.
Location: <expr>:1:10
----- Context ------------------------------------------------------------------
1: (ns user (:require [com.company.example-lambda.core])) (apply com.company.example-lambda.core/-main *command-line-args*)
^--- Could not find namespace: com.company.example-lambda.core.
----- Stack trace --------------------------------------------------------------
user - <expr>:1:10
16 Sep 2022 10:25:45,867 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 1 InvokeID=
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: Could not find namespace: com.company.example-lambda.core.
Location: <expr>:1:10
----- Context ------------------------------------------------------------------
1: (ns user (:require [com.company.example-lambda.core])) (apply com.company.example-lambda.core/-main *command-line-args*)
^--- Could not find namespace: com.company.example-lambda.core.
----- Stack trace --------------------------------------------------------------
user - <expr>:1:10
END RequestId: 5896ce89-a539-4d4e-a1ec-fb4f5e7ddc8a
REPORT RequestId: 5896ce89-a539-4d4e-a1ec-fb4f5e7ddc8a Init Duration: 0.14 ms Duration: 74.94 ms Billed Duration: 75 ms Memory Size: 128 MB Max Memory Used: 128 MB
current template.yml:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Example basic lambda using `holy-lambda` micro library
Parameters:
Timeout:
Type: Number
Default: 40
MemorySize:
Type: Number
Default: 128
Entrypoint:
Type: String
Default: com.company.example-lambda.core
Globals:
Function:
Timeout: !Ref Timeout
MemorySize: !Ref MemorySize
Environment:
Variables:
HL_ENTRYPOINT: !Ref Entrypoint
Resources:
BabashkaDepsLayer:
Type: AWS::Serverless::LayerVersion
Properties:
LayerName: BabashkaDepsLayer
ContentUri: ./.holy-lambda/bb-clj-deps
ExampleLambdaFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: ExampleLambdaFunction
Runtime: provided
Handler: com.company.example-lambda.core.ExampleLambda
CodeUri: .holy-lambda/build/latest.zip
# For docker based deployments use:
# PackageType: Image
# and remove Runtime + CodeUri + Handler
Events:
HelloEvent:
Type: HttpApi
Properties:
ApiId: !Ref ExampleHttpApi
Path: /
Method: GET
Layers:
- arn:aws:lambda:us-east-1:605060902952:layer:holy-lambda-babashka-runtime-amd64:1
- !Ref BabashkaDepsLayer
# For docker based deployments
# Metadata:
# Dockerfile: Dockerfile
# DockerContext: .
# DockerTag: v1
ExampleHttpApi:
Type: AWS::Serverless::HttpApi
Outputs:
ExampleLambdaEndpoint:
Description: Endpoint for ExampleLambdaFunction
Value:
Fn::Sub: https://${ExampleHttpApi}.execute-api.${AWS::Region}.
bb.edn:
{:deps {io.github.FieryCod/holy-lambda-babashka-tasks
{:git/url ""
:deps/root "./modules/holy-lambda-babashka-tasks"
:sha "1469bb96b85c2c65a52df9e3a4914dde1b4c816f"}
io.github.FieryCod/holy-lambda {:mvn/version "0.6.6"}}
;; Minimal babashka version which should be used in conjuction with holy-lambda
:min-bb-version "0.3.7"
:holy-lambda/options {
:docker {
;; Check
;; Network setting for future versions of HL will propagate to AWS SAM as well
;; Options: "host"|"bridge"|"overlay"|"none"|nil|"macvlan"
:network nil
;; HL runs some bb tasks in docker context. You can put additional resources to the context by using volumes.
;; ----------------------------------------------------------------------------
;; Single volume definition:
;;
;; {:docker "/where-to-mount-in-docker"
;; :host "relative-local-path"}
:volumes []
;; GraalVM Community holy-lambda compatible docker image
;; You can always build your own GraalVM image with enterprise edition
:image ""}
:build {:compile-cmd "clojure -X:uberjar"
;; Used when either :docker is nil or
;; `HL_NO_DOCKER` environment variable is set to "true"
;; Might be set via `GRAALVM_HOME` environment variable
:graalvm-home "~/.graalvm"}
:backend
{
;; Babashka pods should be shipped using AWS Lambda Layer
;; Check this template
;; and official docs
;; CodeUri should be `.holy-lambda/pods`
;; For now pods should be declared in `bb.edn`. See:
;;
;; `IMPORTANT:` 3rd party babashka compatible libraries should be distributed as a layers (CodeUri: .holy-lambda/bb-clj-deps)
:pods {}
;; For `:native` backend you can provide your own bootstrap file
:bootstrap-file "bootstrap"
;; For `:native` backend you can provide some native resources which will be available during lambda execution
;; Resources are packed as is.
:native-deps "resources"
;; Specify custom arguments for native image generation
;; Check
:native-image-args ["--verbose"
"--no-fallback"
"--report-unsupported-elements-at-runtime"
"-H:+AllowIncompleteClasspath"
"--no-server"]}}
:tasks {:requires ([holy-lambda.tasks])
hl:docker:run holy-lambda.tasks/hl:docker:run
hl:native:conf holy-lambda.tasks/hl:native:conf
hl:native:executable holy-lambda.tasks/hl:native:executable
hl:babashka:sync holy-lambda.tasks/hl:babashka:sync
hl:compile holy-lambda.tasks/hl:compile
hl:doctor holy-lambda.tasks/hl:doctor
hl:clean holy-lambda.tasks/hl:clean
hl:update-bb-tasks holy-lambda.tasks/hl:update-bb-tasks
hl:version holy-lambda.tasks/hl:version}}
[benj@benj-pc holy-lambda-example]$ tree
.
├── bb.edn
├── deps.edn
├── Dockerfile
├── README.md
├── resources
│ └── native-agents-payloads
│ └── 1.edn
├── src
│ └── com
│ └── company
│ └── example_lambda
│ └── core.cljc
└── template.yml
ah the issue was CodeUri in the function properties.
Properties:
FunctionName: ExampleLambdaFunction
Runtime: provided
Handler: com.company.example-lambda.core.ExampleLambda
CodeUri: src
now it works!@UJ1339K2B it would be easier if the bb walkthrough would just put a snippet of a complete working template.yml (except the arn). Because at that stage I'm just copying the example anyway ^^
👍 1
Oh I see. I hope to find some time to finally make a proper project scaffolding, so that we can get rid of this problem.