Fork me on GitHub
#holy-lambda
<
2022-11-09
>
Jamie Walkerdine16:11:46

Hi folks, relatively new to dealing with custom runtimes + layers in general with AWS, and having an issue with which it is not apparent that I'm doing anything wrong. Attempting to deploy a babashka backend using SAM Here's a snippet from my template.yml

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

  AcquisitionLambdaFn:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: AcquisitionLambdaFn
      Handler: com.nyaya.acquisition.core.ExampleLambda
      CodeUri: src
Upon attempting to deploy with sam deploy --guided --profile my_profile I get the following error
Building codeuri: /home/jam/acquisition/src runtime: provided metadata: {} architecture: x86_64 functions: AcquisitionLambdaFn
Running CustomMakeBuilder:CopySource
Running CustomMakeBuilder:MakeBuild

Build Failed
Error: CustomMakeBuilder:MakeBuild - Makefile not found at /home/jam/acquisition/src/Makefile
and Error: Unable to upload artifact ./.holy-lambda/bb-clj-deps referenced by ContentUri parameter of BabashkaDepsLayer resource. Bucket does not exist As far as I can tell everything is in line with the example. I figured there's probably something invisible here such as the example includes a code signing ARN, or something like that. I don't receive any prompt that suggests SAM realises it's using a local folder for the CodeUri/ContentUri

Karol Wójcik17:11:21

How did you setup the project? Let’s start from the beginning.

Chris Lowe10:11:15

Morning @U04A9F0Q1GU - I couldn’t see the Layers section of your Function properties. See step 3 in the tutorial. I also had to add the Runtime entry, as the template no longer specifies a global default.

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
      Handler: com.company.example-lambda.core.ExampleLambda
      CodeUri: src
      Runtime: provided.al2
      Layers:
        - arn:aws:lambda:eu-west-1:12345678:layer:holy-lambda-babashka-runtime-amd64:1
        - !Ref BabashkaDepsLayer
Replace the line arn:aws:lambda:us-east-1:12345678:layer:holy-lambda-babashka-runtime-amd64:1 with your own physical ID
sam local invoke ExampleLambdaFunction
Invoking com.company.example-lambda.core.ExampleLambda (provided.al2)
Downloading arn:aws:lambda:eu-west-1:12345678:layer:holy-lambda-babashka-runtime-arm64  [####################################]  22724528/22724528
BabashkaDepsLayer is a local Layer in the template
Image was not found.
Building image.....................................................................................................................................................
Skip pulling image and use local one: samcli/lambda:provided.al2-arm64-60629b788a5cc330ec446efa7.

Mounting /Users/lowecg/tmp/holy-lambda-example/src as /var/task:ro,delegated inside runtime container
END RequestId: ae66b1a9-4da6-42fa-ad05-71ce388794de
REPORT RequestId: ae66b1a9-4da6-42fa-ad05-71ce388794de	Init Duration: 0.14 ms	Duration: 54.48 ms	Billed Duration: 55 ms	Memory Size: 128 MB	Max Memory Used: 128 MB
Regarding the “Bucket does not exist” error, can you try adding --resolve-s3 to the sam guided deploy?

Jamie Walkerdine10:11:55

Hi - thanks for your responses. Issue is resolved - I had not provided a bucket for the source! I was under the impression that the error was due to it not finding the artifact in my local directory since the messages were right next to each other and related - thanks for your patience!

Chris Lowe11:11:49

You’re welcome and glad to hear you’re up and running.

Karol Wójcik12:11:10

Thank you @U01RXDR9F4M for helping out the newcomers!