@chris.lowe.uk has joined the channel
Morning @karol.wojcik While the getting started documentation is being worked on, and following on from this https://github.com/FieryCod/holy-lambda/issues/42, the intention here is for me to be a guinea pig and go through the process of deployment with holy-lambda to discover what sort things to cover in the docs. Where I am: I’m coming into this cold from both a holy-lambda and babashka perspective. I am familiar with using Lambda’s (mostly node.js to date) and have had very fleeting experiences with SAM. My goal: Create a Clojure Java Native Lambda that, in response to S3 events, transforms file content between two S3 buckets (input and output). I’ll add what I can to this thread which will, hopefully, be of use to others.
Answering your questions; 1. Lein new or clj-new will always generate the core.cljc with a single lambda ExampleLambdaFunction. It’s declared in template.yml since it’s just AWS SAM file. On bb.edn you declare the default function which should be invoked or which lambda logs should be taken from cloud watch when bb stack:invoke or bb stack:logs are invoked. Default function might be overridden by passing your function name to those commands ;) runtime should be changed by specifying different name of the runtime in bb.edn. bb stack:sync is required after doing so. 2. bb stack:sync syncs required dependencies for the stack. It downloads deps, deploys necessary layers and sync babashka pods. It’s very useful since you don’t want to pack all the dependencies from /$HOME/.m2 but rather the dependencies you use in your project. ;) I would rather not change the name of the command. bb stack:sync sometimes deploys the layer (and will in future auto update the version of the layer) 3. default profile is used, but maybe it should be changed?
lein new holy-lambda holy-lambda-gs
cd holy-lambda-gs
git init
git add .
git commit -m 'initial checkin'This will be done on a Mac (Big Sur with brew)
Install https://github.com/babashka/babashka (the project doesn’t appear to be linked anywhere from HL docs)
bash < <(curl -s )
This installs babashka globally.From the git folder, verify the babashka install worked:
holy-lambda-gs (main) $ ls | bb -i '(filter #(-> % io/file .isDirectory) *input*)'
("resources" "src")Template change request:
Using bb generates a folder .cpcache, can this be added to .gitignore?
holy-lambda-gs (main) $ git status .
On branch main
Untracked files:
(use "git add <file>..." to include in what will be committed)
.cpcache/Thanks. I've added it to .gitignore. Will be available in next release 🙂
Ok, where to begin.
Initial advice (issue comment) was to run bb stack:sync and use bb stack:doctor
But I am coming at this completely cold. There are questions at this point :-)
Question 1: In generating the project using lein, what do I have? It would be good to have an overview of what would be produced, e.g.
this will create a Lambda function named XXX, running on runtime YY Y (or whatever)
• how you rename the Lambda function (there are references to ExampleLambdaFunction in template.yml and bb.edn)?
• how do you choose and configure a runtime (JVM, GraalVM, babashka)?
Question 2: What does stack:sync do exactly?
From README.md,
> stack:sync > Syncs project & dependencies from either:
> - <Clojure> project.clj
> - <Clojure> deps.edn
> - <Babashka> bb.edn:runtime:pods
In a AWS world, the use of terminology could be confusing, we will produce code and deploy (sync) code to the cloud.
Would something like “init-deps” be a better choice here?
Question 3: I’m used to having to perform some sort of AWS init to set my creds. Where should that happen? Or is HL just using the default profile?
Running bb stack:sync failed for me:
holy-lambda-gs (main) $ bb stack:sync
[holy-lambda] Command <stack:sync>
[holy-lambda] Project not synced yet. Syncing with docker image!
[holy-lambda] Project did not sync properly. Remove .holy-lambda directory and run stack:sync
----- Error --------------------------------------------------------------------
Type: java.io.FileNotFoundException
Message: .holy-lambda/clojure/deps.edn (No such file or directory)I followed the recommendation to remove .holy-lambda and try again, but had the same result:
holy-lambda-gs (main) $ rm -rf .holy-lambda/
holy-lambda-gs (main) $ bb stack:sync
[holy-lambda] Command <stack:sync>
[holy-lambda] Project not synced yet. Syncing with docker image!
[holy-lambda] Unable to sync docker image content with .holy-lambda project directory!
[holy-lambda] Project did not sync properly. Remove .holy-lambda directory and run stack:sync
----- Error --------------------------------------------------------------------
Type: java.io.FileNotFoundException
Message: .holy-lambda/clojure/deps.edn (No such file or directory)(currently running stack:doctor)
Command reports something is missing
...
[holy-lambda] Commands ("clj-kondo") not found. Install all then run: bb doctorTry bb stack:prune then bb stack:sync
I will check new template
Looks like the prune task is not available in the template I used:
bb stack:prune
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: File does not exist: stack:pruneSorry. It should be bb stack:purge
np. same result:
holy-lambda-gs (main) $ bb stack:purge
[holy-lambda] Command <stack:purge>
[holy-lambda] Purging build artifacts:
- .aws
- .holy-lambda
- .cpcache
-
- node_modules
[holy-lambda] Build artifacts purged
holy-lambda-gs (main) $ bb stack:sync
Downloading: org/clojure/clojure/1.10.3/clojure-1.10.3.pom from central
Downloading: org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.pom from central
Downloading: org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.pom from central
Downloading: org/clojure/pom.contrib/0.3.0/pom.contrib-0.3.0.pom from central
Downloading: io/github/FieryCod/holy-lambda/0.1.45/holy-lambda-0.1.45.pom from clojars
Downloading: com/amazonaws/aws-lambda-java-core/1.2.1/aws-lambda-java-core-1.2.1.pom from central
Downloading: io/github/FieryCod/holy-lambda-default-retriever/0.0.5/holy-lambda-default-retriever-0.0.5.pom from clojars
Downloading: metosin/jsonista/0.3.2/jsonista-0.3.2.pom from clojars
Downloading: com/fasterxml/jackson/core/jackson-core/2.12.2/jackson-core-2.12.2.pom from central
Downloading: com/fasterxml/jackson/core/jackson-databind/2.12.2/jackson-databind-2.12.2.pom from central
Downloading: com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.12.2/jackson-datatype-jsr310-2.12.2.pom from central
Downloading: com/fasterxml/jackson/jackson-base/2.12.2/jackson-base-2.12.2.pom from central
Downloading: com/fasterxml/jackson/module/jackson-modules-java8/2.12.2/jackson-modules-java8-2.12.2.pom from central
Downloading: com/fasterxml/jackson/jackson-bom/2.12.2/jackson-bom-2.12.2.pom from central
Downloading: com/fasterxml/jackson/jackson-parent/2.12/jackson-parent-2.12.pom from central
Downloading: com/fasterxml/oss-parent/41/oss-parent-41.pom from central
Downloading: com/fasterxml/jackson/core/jackson-annotations/2.12.2/jackson-annotations-2.12.2.pom from central
Downloading: com/fasterxml/jackson/core/jackson-core/2.12.2/jackson-core-2.12.2.jar from central
Downloading: org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar from central
Downloading: com/fasterxml/jackson/core/jackson-databind/2.12.2/jackson-databind-2.12.2.jar from central
Downloading: com/fasterxml/jackson/core/jackson-annotations/2.12.2/jackson-annotations-2.12.2.jar from central
Downloading: org/clojure/clojure/1.10.3/clojure-1.10.3.jar from central
Downloading: org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar from central
Downloading: io/github/FieryCod/holy-lambda/0.1.45/holy-lambda-0.1.45.jar from clojars
Downloading: com/amazonaws/aws-lambda-java-core/1.2.1/aws-lambda-java-core-1.2.1.jar from central
Downloading: com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.12.2/jackson-datatype-jsr310-2.12.2.jar from central
Downloading: io/github/FieryCod/holy-lambda-default-retriever/0.0.5/holy-lambda-default-retriever-0.0.5.jar from clojars
Downloading: metosin/jsonista/0.3.2/jsonista-0.3.2.jar from clojars
[holy-lambda] Command <stack:sync>
[holy-lambda] Project not synced yet. Syncing with docker image!
[holy-lambda] Project did not sync properly. Remove .holy-lambda directory and run stack:sync
----- Error --------------------------------------------------------------------
Type: java.io.FileNotFoundException
Message: .holy-lambda/clojure/deps.edn (No such file or directory) @chris.lowe.uk What is you template version? It should be: 0.1.52
ls ~/.m2/repository/holy-lambda/lein-template/
0.1.52 maven-metadata-clojars.xml maven-metadata-clojars.xml.sha1 resolver-status.propertieslooks like I’m using the expected version
Could you please send whole report from bb stack:doctor?
bb stack:doctor
[holy-lambda] Command <stack:doctor>
[holy-lambda] ---------------------------------------
[holy-lambda] Checking health of holy-lambda stack
[holy-lambda] Home directory is: /Users/lowecg
[holy-lambda] AWS directory is: /Users/lowecg/.aws
[holy-lambda] Babashka tasks version: 0.0.1
[holy-lambda] Babashka version: babashka v0.4.1
[holy-lambda] Runtime: :native
[holy-lambda] Runtime entrypoint: holy-lambda-gs.core
[holy-lambda] Stack name: holy-lambda-template-stack
[holy-lambda] S3 Bucket name: holy-lambda-template-bucket
[holy-lambda] S3 Bucket prefix: holy-lambda
[holy-lambda] ---------------------------------------
[holy-lambda] :runtime looks good
[holy-lambda] :runtime:entrypoint looks good
[holy-lambda] :stack:capabilities looks good
[holy-lambda] :runtime:bootstrap-file does not exists. Default bootstrap file for :native runtime will be used!
[holy-lambda] :runtime:version is supported only for :babashka runtime
[holy-lambda] :runtime:pods are supported only for :babashka runtime
[holy-lambda] :stack:name looks good
[holy-lambda] property :mvn/local-repo in file deps.edn is correct
[holy-lambda] property :mvn/local-repo in file bb.edn is correct
[holy-lambda] Stack is not synced! Run: stack:sync
[holy-lambda] :infra:region definition looks good
[holy-lambda] :infra:bucket-prefix looks good
[holy-lambda] :stack:template looks good
[holy-lambda] :infra:bucket-name looks good, but holy-lambda-template-bucket does not exists (use bb :bucket:create)
[holy-lambda] Required commands ["aws" "sam" "bb" "docker" "clojure" "zip" "id" "clj-kondo" "bash"] installed!
[holy-lambda] Validating template.yml
SAM CLI now collects telemetry to better understand customer needs.
You can OPT OUT and disable telemetry collection by setting the
environment variable SAM_CLI_TELEMETRY=0 in your shell.
Thanks for your help!
Learn More:
2021-05-14 09:33:09 Loading policies from IAM...
2021-05-14 09:33:12 Finished loading policies from IAM.
/Users/lowecg/source/private-github/holy-lambda-gs/template.yml is a valid SAM Template I’ve since installed https://github.com/clj-kondo/clj-kondo/blob/master/doc/install.md
brew install borkdude/brew/clj-kondoYour stack looks good. I'm wondering what might go wrong in that setup. I will need some more of your help. May we have a quick call?
sure thing - give me 15 mins.
Just let me know when you're ready 🙂
ready
Send you a invitation link in private 🙂
For the benefit of this thread - the cause of the stack:sync issue was docker not running. Some additional docker checks will be built into the bb tasks to better protect people, like me, from themselves!
Thank you @chris.lowe.uk @martinklepsch for today bug hunting! I will get on those bugs today's evening or early in the morning. I will notify you, when I finish so that you can retest 🙂
• @martinklepsch https://github.com/FieryCod/holy-lambda/issues/43 It has been fixed in https://github.com/FieryCod/holy-lambda/commit/f40e9e0a5ec5870211ceded1084b478c03d1e6ae Please use https://github.com/FieryCod/holy-lambda/commit/f40e9e0a5ec5870211ceded1084b478c03d1e6ae for babashka tasks and let me know whether it works on your end. • @chris.lowe.uk @martinklepsch Bucket creation will now fail early: https://github.com/FieryCod/holy-lambda/commit/b11cb73600f6dbbeb6b1e364c5346d9fdde8fc0a Please try to use common bucket name like "example", and report if it works on your end 🙂 • @chris.lowe.uk bb stack:sync will not run if docker is not running 🙂 https://github.com/FieryCod/holy-lambda/commit/474729795b70864246fba6062c3ea02fdbad2324
Good example of poka-yoke 😄